![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
http://www.ibm.com/developerworks/da...cle/dm-1007inf... phallage <P... (AT) Hallager (DOT) dk Sent by: informix-list-boun... (AT) iiug (DOT) org 13/10/2011 17:17 To informix-l... (AT) iiug (DOT) org cc Subject 4GL Read file Hi, I want to use the new OPEN FILE, READ FILE, CLOSE FILE in Informix 4GL. Could anyone direct me to detailed documentation on it? I can't find any description on how to detect EOF in the READ statement as the READ statement does not seem to return a flag. Any help will be appreciated. Poul H. _______________________________________________ Informix-list mailing list Informix-l... (AT) iiug (DOT) orghttp://www.iiug.org/mailman/listinfo/informix-list |
#4
| |||
| |||
|
|
Hi, I want to use the new OPEN FILE, READ FILE, CLOSE FILE in Informix 4GL. Could anyone direct me to detailed documentation on it? I can't find any description on how to detect EOF in the READ statement as the READ statement does not seem to return a flag. Any help will be appreciated. Poul H. _______________________________________________ Informix-list mailing list Informix-list (AT) iiug (DOT) org http://www.iiug.org/mailman/listinfo/informix-list I haven't played with it, but looking at the docs, it doesn't seem to me like |
#5
| |||
| |||
|
|
On 13/10/11 12:47, phallage wrote:> Hi, I want to use the new OPEN FILE, READ FILE, CLOSE FILE in Informix 4GL. Could anyone direct me to detailed documentation on it? I can't find any description on how to detect EOF in the READ statement as the READ statement does not seem to return a flag. Any help will be appreciated. Poul H. _______________________________________________ Informix-list mailing list Informix-l... (AT) iiug (DOT) org http://www.iiug.org/mailman/listinfo/informix-list I haven't played with it, but looking at the docs, it doesn't seem to me like you can detect EOF at all. If all else fails, in 1996 or thereabout I had written a IO package for 4gl which does exactly what you want and more: head to the IIUG software repository and look for the fglio package. Alternatively, you can find it in my little web site, athttp://www.4glworks.com/misc.htm -- Ciao, Marco __________________________________________________ _________________________*___ Marco Greco /UK /IBM * * * * * * * * * * * * * * * Standard disclaimers apply! Structured Query Scripting Language * * * * *http://www.4glworks.com/sqsl.htm 4glworks * * * * * * * * * * * * * * * * * * * * * * *http://www.4glworks.com Informix on Linux * * * * * * * * * * * *http://www.4glworks.com/ifmxlinux.htm |
#6
| |||
| |||
|
|
I want to use the new OPEN FILE, READ FILE, CLOSE FILE in Informix 4GL. Could anyone direct me to detailed documentation on it? I can't find any description on how to detect EOF in the READ statement as the READ statement does not seem to return a flag. |
|
-4828 The field to be read from the file file_name should not be greater than 4096 bytes. |
|
The length of the string read from the file exceeds 4096 bytes. Check the field in the file. Possibly, the file delimiter is misplaced. |
#7
| |||
| |||
|
|
On Thu, Oct 13, 2011 at 04:47, phallage <P... (AT) hallager (DOT) dk> wrote: I want to use the new OPEN FILE, READ FILE, CLOSE FILE in Informix 4GL. Could anyone direct me to detailed documentation on it? I can't find any description on how to detect EOF in the READ statement as the READ statement does not seem to return a flag. I4GL programs should work off STATUS, roughly like this: -- Testing I4GL Direct File I/O and EOF handling MAIN * * DEFINE username * * VARCHAR(32) * * DEFINE password * * VARCHAR(32) * * DEFINE uid * * * * *INTEGER * * DEFINE gid * * * * *INTEGER * * DEFINE comment * * *VARCHAR(64) * * DEFINE home * * * * VARCHAR(128) * * DEFINE shell * * * *VARCHAR(64) * * DEFINE fd * * * INTEGER * * WHENEVER ERROR CONTINUE * * OPEN FILE fd FROM "/etc/passwd" *OPTIONS(READ, FORMAT = 'load', DELIMITER = ':') * * IF STATUS != 0 THEN * * * * DISPLAY "Failed to open /etc/passwd for reading" * * * * EXIT PROGRAM 1 * * END IF * * WHILE STATUS = 0 * * * * READ FROM fd INTO username, *password, uid, gid, comment, home, shell * * * * IF STATUS != 0 THEN * * * * * * EXIT WHILE * * * * END IF * * * * DISPLAY "Entry: ", username CLIPPED, * * * * * * * * " (", password CLIPPED, "),", * * * * * * * * " [UID=", uid USING "-----&", ", GID=", gid USING "-----&", "]", * * * * * * * * " Home = <<", home CLIPPED, ">>,", * * * * * * * * " Shell = <<", shell CLIPPED, ">>" * * END WHILE * * IF STATUS < 0 THEN * * * * DISPLAY "Read error", STATUS * * ELSE * * * * DISPLAY "EOF found" * * END IF * * CLOSE FILE fd END MAIN Unfortunately, this stopped abruptly with error -1215 on the machine I tested with...there was a user: nfsnobody:!!:4294967294:4294967294:Anonymous NFS User:/var/lib/nfs:/sbin/nologin The error is accurate; that number is too big to fit into a 4-byte integer. Things went downhill after that. Change the type of UID and GID to BIGINT and the display stops displaying numbers (in I4GL p-code; the c-code system worked OK). It does however end reading to the end of the file, but then generates error -4828: -4828 * *The field to be read from the file file_name should not be greater than 4096 bytes. The length of the string read from the file exceeds 4096 bytes. Check the field in the file. Possibly, the file delimiter is misplaced. Neither is acceptable behaviour - though they are independent bugs. *Inmy estimation, the READ should return NOTFOUND on EOF. Tested: I4GL 7.50.FC4 on RHEL 5 (Linux x86/64). The p-code DISPLAY of BIGINT bug is CQ idsdb00234046. The EOF from READ bug is CQ idsdb00234047. -- Jonathan Leffler <jonathan.leff... (AT) gmail (DOT) com> *#include <disclaimer.h Guardian of DBD::Informix - v2011.0612 -http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." |
![]() |
| Thread Tools | |
| Display Modes | |
| |