4gl not ending FOR loop thru file for IDS ver 12.1
Posted in 2019
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues, Versions, Editions & End-of-Life
Question, we are using a 4gl program code that reads a file, which contains email addresses. In IDS 11.50, we do not have to add a blank line at the bottom of the list file. We are having to add a blank line to the bottom of the list file while using IDS ver 12.10. Otherwise the FOR loop continues 1000 times. Has anyone experienced this issue for resolution? IDS: IBM Informix Dynamic Server Version 12.10.FC10 OS: AIX 7.2 4GL / ISQL: 7.51.FC2 CSDK / ESQL: 4.10.FC10 CODE: ok - this is the commands that send the email: LET f_cmd = "test -f ", f_file_name RUN f_cmd RETURNING f_result IF NOT f_result THEN --File found OPEN FILE f_file FROM f_file_name OPTIONS (READ, FORMAT = "text") FOR f_i = 1 TO 1000 READ FROM f_file INTO f_mail_add IF f_mail_add IS NULL THEN EXIT FOR END IF LET f_cmd = "mail -s \\\\"", f_subj_line CLIPPED,"\\\\""," ", f_mail_add CLIPPED ,"< ", m_mail_path CLIPPED LET f_cmd = f_cmd CLIPPED CALL run_system_cmd(f_cmd) END FOR CLOSE FILE f_file END IF
Update from IBM: 14 May 2019 3:24 PM I'm wondering if it's related to this defect which was fixed in 4GL 7.51.xC1: APAR IC93179 - 4GL: BEHAVIOR OF CLIPPED HAS CHANGED FROM VERSION 7.32 TO 7.50 Error Description -------------------------------------------------------------------------------- -- In version 7.32.xxx of IBM Informix 4GL, CLIPPED removed only trailing spaces. In version 7.50.xxx of IBM Informix 4GL, CLIPPED also removes the line feed character. We are using: IBM INFORMIX-4GL Version 7.51.FC2, which still seem to be an issue with the use of CLIPPED.
From IBM: I presented this issue to Informix Development and you are correct, there is a change in behaviour since 7.50.xC4. Below is our analysis with another workaround at the end. Let me know what you think. Regards, --XXX We did a quick test on a Linux box and see a difference between old and new: informix@irk:/tmp$ cat open.4gl database sysmaster DEFINE f_file_name varchar(20), f_mail_add varchar(255), f_subj_line varchar(255), m_mail_path varchar(255), f_cmd varchar(255) , f_file int, f_i int main let f_file_name="./open.txt" let f_subj_line="4glemail" let m_mail_path="testpath" OPEN FILE f_file FROM f_file_name OPTIONS (READ, FORMAT = "text") FOR f_i = 1 TO 10 display f_mail_add READ FROM f_file INTO f_mail_add display f_mail_add IF f_mail_add IS NULL THEN EXIT FOR END IF LET f_cmd = "mail -s \\\\"", f_subj_line CLIPPED,"\\\\""," ", f_mail_add CLIPPED ,"< ", m_mail_path CLIPPED LET f_cmd = f_cmd CLIPPED display f_cmd run f_cmd #CALL run_system_cmd(f_cmd) END FOR CLOSE FILE f_file end main informix@irk:/tmp$ cat open.txt line 1 line 2 line 3 informix@irk:/tmp$ With 7.50.FC5: informix@irk:/tmp$ c4gl -V IBM INFORMIX-4GL Version 7.50.FC5 Software Serial Number RDS#N000000 informix@irk:/tmp$ c4gl open.4gl informix@irk:/tmp$ ./a.out line 1 mail -s "4glemail" line 1< root@test.com bash: root@test.com: No such file or directory line 1 line 2 mail -s "4glemail" line 2< root@test.com bash: root@test.com: No such file or directory line 2 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 informix@irk:/tmp$ With 7.51.FC2: informix@irk:/tmp$ c4gl -V IBM INFORMIX-4GL Version 7.51.FC2 Software Serial Number RDS#N000000 informix@irk:/tmp$ c4gl open.4gl informix@irk:/tmp$ ./a.out line 1 mail -s "4glemail" line 1< root@test.com bash: root@test.com: No such file or directory line 1 line 2 mail -s "4glemail" line 2< root@test.com bash: root@test.com: No such file or directory line 2 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory informix@irk:/tmp$ 7.51 needs an empty new line at the end of the file, otherwise the variable will not be NULL and it will not exit the loop (repeting the last line) I think that why CLIPPED internally works on 7.50. Having a new line it will exit the loop: informix@irk:/tmp$ cat open.txt line 1 line 2 line 3 informix@irk:/tmp$ ./a.out line 1 mail -s "4glemail" line 1< root@test.com bash: root@test.com: No such file or directory line 1 line 2 mail -s "4glemail" line 2< root@test.com bash: root@test.com: No such file or directory line 2 line 3 mail -s "4glemail" line 3< root@test.com bash: root@test.com: No such file or directory line 3 informix@irk:/tmp$ Another option is to NULL the variable before it does the next iteraction: .... display f_cmd run f_cmd #CALL run_system_cmd(f_cmd) LET f_mail_add = NULL END FOR CLOSE FILE f_file