Re: Help! 4GL Program Question.
Posted in 2000
Topics: SQL Development & Query Writing, Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Triggers, Constraints & Referential Integrity, Jobs, Consulting & Announcements
This is a multi-part message in MIME format. --------------26B1F4A84D40189D7D3983F4 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Yes Dennis this is what I was heading, In fact if we have a SPL which wakes up during insert and call 'C' routine which in turn will display a message should be okay. In this scenario there is no overhead on either of the programs as there is polling within 4gl or 'C'. I had implemented couple of years back this scenario which I did not throw any surprises. Rgds William Rice wrote: > It depends how real time this has to be > Might you have a trigger to insert the primary key of table 1 into a table 2. > Have the second program query the second table as often as you like, > and bring new records up from table 1, and delete the entry in table 2. > > You might throw a datetime into table 2 as well > > Requires no programming changes for the inserting program, and only > makes me flinch a little. > > Will > >===== Original Message From "Dennis Pimple" <dennisp@informix.com> ===== > >Chetan Anand <canand@systems.dhl.com> wrote in message > >news:38B46FD4.E4EC75E@systems.dhl.com... > >> Daniel: > >> > >> Use trigger on the insert table in conjuction with an SPL. > >> > >... which would do a SYSTEM call to launch the 2nd 4GL program, is where I > >think Chetan was headed. If the 2nd 4GL program is already running, however, > >you will have to be in a polling loop of some sort; there's no good way to > >raise an event that branches program logic in 4GL (outside of the normal > >MENU, INPUT, etc statements). Which means if your end user is supposed to be > >doing something else while waiting for the 1st program to insert the row, > >you're in trouble. > > > >If it's ok for the 2nd program to be "idle" waiting for the insert, the > >problem is surmountable: > > > >prepare a cursor with the select statement that gets the row from the first > >4gl program > >let int_flag = false > >while true > > open the cursor > > fetch the cursor > > if sqlca.sqlerrd = notfound then > > sleep for a bit > > else > > call the function that displays the row > > exit while # ? if you want to leave after a successful fetch; > >otherwise continue looping > > # make sure the inserted row is deleted or modified so the same row > >won't be fetched again. > > end if > > if int_flag = true then > > # if the user hits the interrupt key, they can break out of the loop > >before a row is fetched > > let int_flag = false > > exit while > > end if > >end while > > > >Or some variation of the above. > > > >The only other approach I can think of is 'c'-level calls that can post > >interrupts to the program and force branching. I think it could be done, but > >not by moi. > > > >> > Hi: > >> > I have two INFORMIX 4GL programs.I want if the first one insert a > >row > >> > into the database,the second one can trap this and do some display on > >it's > >> > screen.Can I do it with 4GL only,Or I must use C instead. > >> > Please Help Me! > >> > I'll killed if I can't finished the project this weekend! > >> > > >> > My email is pangq@zhej.piccnet.com.cn > >> > > >> > Any and all information is welcome. > >> > > >> > Thanks, > >> > > >> > Danny > > > > > >-- > >======================================================= > >Dennis J. Pimple Informix Software, Inc. > >Principal Consultant 6300 S Syracuse Way Ste 205 > >dennisp@informix.com Englewood CO 80111 > >office: 303-850-0210 > >direct: 303-740-5611 Opinions expressed are mine, > > fax: 303-779-4025 and do not necessarily > > reflect those of my employer. > > > >http://www.informix.com > > ------------------------------------------------------------ > This e-mail has been sent to you courtesy of OperaMail, as a free service from > Opera Software, makers of the award-winning Web Browser, Opera. Visit us at > http://www.opera.com/ or our portal at: http://www.myopera.com/ Your free e-mail > account is waiting at: http://www.operamail.com/ > ------------------------------------------------------------ --------------26B1F4A84D40189D7D3983F4 Content-Type: text/x-vcard; charset=us-ascii; name="canand.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Chetan Anand Content-Disposition: attachment; filename="canand.vcf" begin:vcard n:Anand;Chetan tel;fax:<b><i>413+ 647-9311</i></b> tel;work:<b>650+ 425-5327</b> x-mozilla-html:TRUE org:<img src=http://www.dhl.com/art/logo.gif> <br> <b>DHL Systems Inc. </b> version:2.1 email;internet:canand@systems.dhl.com title:<i>Senior Software Engineer</i> adr;quoted-printable:;;700 Airport Blvd=0D=0ASuite 300;Burlingame;California;94010;USA fn:Chetan Anand end:vcard --------------26B1F4A84D40189D7D3983F4--
Yes,I think I'm in trouble now.Then now I turn my face to C,but there're new problem!How I can implement a 4gl program call a C function and in the C function Call a 4gl function define in the original 4gl program. Look at my source Code in C parts: #include <stdio.h> #include <stdlib.h> void s1(int); void s2(int); int j = 1; int my_sighandle(int nargs) { int i; i = fork(); switch(i) { case 0: signal(SIGUSR1,s1); signal(SIGUSR2,s2); while(j) { test_disp(); sleep(1); } retint(0); break; case -1: retint(-1); break; default: retint(i); } return 1; } void s1(int k) { j = 2; signal(SIGUSR1,s1); return; } void s2(int k) { j = 0; return; } I define a signal handle of my own.I can the function my_sighandle in the very begin of the 4gl main program.I use the son process to trap the signal,and then call the 4gl function to display a message on the user's screen.I can compile and link the program.When it runs,everything is OK(include the test_disp 4gl function),but when I send a signle to this process,sth. strange will happen,the son process will stop and display error message: Program stopped at "car1102.4gl", line number 105. FORMS statement error number -1318. A parameter count mismatch has occurred between the calling function and the called function. the 105 line of car1102.4gl is the test_disp function Function test_disp Define aaa Char(10) Let aaa = "1231" Message aaa End Function I really troubled by this:why everything is OK,but if it received a signal,it will wrong! Chetan Anand <canand@systems.dhl.com> wrote in message news:896ppv$rh1$1@news.xmission.com... > > This is a multi-part message in MIME format. > --------------26B1F4A84D40189D7D3983F4 > Content-Type: text/plain; charset=us-ascii > Content-Transfer-Encoding: 7bit > > Yes Dennis this is what I was heading, In fact if we have a SPL which wakes up during > insert and call 'C' routine which in turn will display a message should be okay. In > this scenario there is no overhead on either of the programs as there is polling within > 4gl or 'C'. > > I had implemented couple of years back this scenario which I did not throw any > surprises. > > Rgds > > > William Rice wrote: > > > It depends how real time this has to be > > Might you have a trigger to insert the primary key of table 1 into a table 2. > > Have the second program query the second table as often as you like, > > and bring new records up from table 1, and delete the entry in table 2. > > > > You might throw a datetime into table 2 as well > > > > Requires no programming changes for the inserting program, and only > > makes me flinch a little. > > > > Will > > >===== Original Message From "Dennis Pimple" <dennisp@informix.com> ===== > > >Chetan Anand <canand@systems.dhl.com> wrote in message > > >news:38B46FD4.E4EC75E@systems.dhl.com... > > >> Daniel: > > >> > > >> Use trigger on the insert table in conjuction with an SPL. > > >> > > >... which would do a SYSTEM call to launch the 2nd 4GL program, is where I > > >think Chetan was headed. If the 2nd 4GL program is already running, however, > > >you will have to be in a polling loop of some sort; there's no good way to > > >raise an event that branches program logic in 4GL (outside of the normal > > >MENU, INPUT, etc statements). Which means if your end user is supposed to be > > >doing something else while waiting for the 1st program to insert the row, > > >you're in trouble. > > > > > >If it's ok for the 2nd program to be "idle" waiting for the insert, the > > >problem is surmountable: > > > > > >prepare a cursor with the select statement that gets the row from the first > > >4gl program > > >let int_flag = false > > >while true > > > open the cursor > > > fetch the cursor > > > if sqlca.sqlerrd = notfound then > > > sleep for a bit > > > else > > > call the function that displays the row > > > exit while # ? if you want to leave after a successful fetch; > > >otherwise continue looping > > > # make sure the inserted row is deleted or modified so the same row > > >won't be fetched again. > > > end if > > > if int_flag = true then > > > # if the user hits the interrupt key, they can break out of the loop > > >before a row is fetched > > > let int_flag = false > > > exit while > > > end if > > >end while > > > > > >Or some variation of the above. > > > > > >The only other approach I can think of is 'c'-level calls that can post > > >interrupts to the program and force branching. I think it could be done, but > > >not by moi. > > > > > >> > Hi: > > >> > I have two INFORMIX 4GL programs.I want if the first one insert a > > >row > > >> > into the database,the second one can trap this and do some display on > > >it's > > >> > screen.Can I do it with 4GL only,Or I must use C instead. > > >> > Please Help Me! > > >> > I'll killed if I can't finished the project this weekend! > > >> > > > >> > My email is pangq@zhej.piccnet.com.cn > > >> > > > >> > Any and all information is welcome. > > >> > > > >> > Thanks, > > >> > > > >> > Danny > > > > > > > > >-- > > >======================================================= > > >Dennis J. Pimple Informix Software, Inc. > > >Principal Consultant 6300 S Syracuse Way Ste 205 > > >dennisp@informix.com Englewood CO 80111 > > >office: 303-850-0210 > > >direct: 303-740-5611 Opinions expressed are mine, > > > fax: 303-779-4025 and do not necessarily > > > reflect those of my employer. > > > > > >http://www.informix.com > > > > ------------------------------------------------------------ > > This e-mail has been sent to you courtesy of OperaMail, as a free service from > > Opera Software, makers of the award-winning Web Browser, Opera. Visit us at > > http://www.opera.com/ or our portal at: http://www.myopera.com/ Your free e-mail > > account is waiting at: http://www.operamail.com/ > > ------------------------------------------------------------ > > --------------26B1F4A84D40189D7D3983F4 > Content-Type: text/x-vcard; charset=us-ascii; > name="canand.vcf" > Content-Transfer-Encoding: 7bit > Content-Description: Card for Chetan Anand > Content-Disposition: attachment; > filename="canand.vcf" > > begin:vcard > n:Anand;Chetan > tel;fax:<b><i>413+ 647-9311</i></b> > tel;work:<b>650+ 425-5327</b> > x-mozilla-html:TRUE > org:<img src=http://www.dhl.com/art/logo.gif> <br> <b>DHL Systems Inc. </b> > version:2.1 > email;internet:canand@systems.dhl.com > title:<i>Senior Software Engineer</i> > adr;quoted-printable:;;700 Airport Blvd=0D=0ASuite 300;Burlingame;California;
The information you need is in the manual, where there are sections discussing both calling C functions from I4GL code and calling I4GL code from C functions. All I4GL functions have the signature "extern int function(int nargs);", where the input number is the number of arguments you pushed onto the I4GL stack, and the return value is the number of return values pushed onto the I4GL stack for retrieval by the calling function. Now work out why your code is wrong. Daniel Pan wrote: > Yes,I think I'm in trouble now.Then now I turn my face to C,but there're new > problem!How I can implement a 4gl program call a C function and in the C > function Call a 4gl function define in the original 4gl program. > Look at my source Code in C parts: > > #include <stdio.h> > #include <stdlib.h> > > void s1(int); > void s2(int); > int j = 1; > > int my_sighandle(int nargs) > { > int i; > > i = fork(); > switch(i) > { > case 0: > signal(SIGUSR1,s1); > signal(SIGUSR2,s2); > while(j) > { > test_disp(); > sleep(1); > } > retint(0); > break; > case -1: > retint(-1); > break; > default: > retint(i); > } > return 1; > } > > void s1(int k) > { > j = 2; > signal(SIGUSR1,s1); > return; > } > void s2(int k) > { > j = 0; > return; > } > I define a signal handle of my own.I can the function my_sighandle in the > very begin of the 4gl main program.I use the son process to trap the > signal,and then call the 4gl function to display a message on the user's > screen.I can compile and link the program.When it runs,everything is > OK(include the test_disp 4gl function),but when I send a signle to this > process,sth. strange will happen,the son process will stop and display error > message: > > Program stopped at "car1102.4gl", line number 105. > FORMS statement error number -1318. > A parameter count mismatch has occurred between the calling > function and the called function. > the 105 line of car1102.4gl is the test_disp function > > Function test_disp > Define aaa Char(10) > Let aaa = "1231" > Message aaa > End Function > > I really troubled by this:why everything is OK,but if it received a > signal,it will wrong! > > Chetan Anand <canand@systems.dhl.com> wrote in message > news:896ppv$rh1$1@news.xmission.com... > > > > This is a multi-part message in MIME format. > > --------------26B1F4A84D40189D7D3983F4 > > Content-Type: text/plain; charset=us-ascii > > Content-Transfer-Encoding: 7bit > > > > Yes Dennis this is what I was heading, In fact if we have a SPL which > wakes up during > > insert and call 'C' routine which in turn will display a message should be > okay. In > > this scenario there is no overhead on either of the programs as there is > polling within > > 4gl or 'C'. > > > > I had implemented couple of years back this scenario which I did not throw > any > > surprises. > > > > Rgds > > > > > > William Rice wrote: > > > > > It depends how real time this has to be > > > Might you have a trigger to insert the primary key of table 1 into a > table 2. > > > Have the second program query the second table as often as you like, > > > and bring new records up from table 1, and delete the entry in table 2. > > > > > > You might throw a datetime into table 2 as well > > > > > > Requires no programming changes for the inserting program, and only > > > makes me flinch a little. > > > > > > Will > > > >===== Original Message From "Dennis Pimple" <dennisp@informix.com> > ===== > > > >Chetan Anand <canand@systems.dhl.com> wrote in message > > > >news:38B46FD4.E4EC75E@systems.dhl.com... > > > >> Daniel: > > > >> > > > >> Use trigger on the insert table in conjuction with an SPL. > > > >> > > > >... which would do a SYSTEM call to launch the 2nd 4GL program, is > where I > > > >think Chetan was headed. If the 2nd 4GL program is already running, > however, > > > >you will have to be in a polling loop of some sort; there's no good way > to > > > >raise an event that branches program logic in 4GL (outside of the > normal > > > >MENU, INPUT, etc statements). Which means if your end user is supposed > to be > > > >doing something else while waiting for the 1st program to insert the > row, > > > >you're in trouble. > > > > > > > >If it's ok for the 2nd program to be "idle" waiting for the insert, the > > > >problem is surmountable: > > > > > > > >prepare a cursor with the select statement that gets the row from the > first > > > >4gl program > > > >let int_flag = false > > > >while true > > > > open the cursor > > > > fetch the cursor > > > > if sqlca.sqlerrd = notfound then > > > > sleep for a bit > > > > else > > > > call the function that displays the row > > > > exit while # ? if you want to leave after a successful fetch; > > > >otherwise continue looping > > > > # make sure the inserted row is deleted or modified so the > same row > > > >won't be fetched again. > > > > end if > > > > if int_flag = true then > > > > # if the user hits the interrupt key, they can break out of the > loop > > > >before a row is fetched > > > > let int_flag = false > > > > exit while > > > > end if > > > >end while > > > > > > > >Or some variation of the above. > > > > > > > >The only other approach I can think of is 'c'-level calls that can post > > > >interrupts to the program and force branching. I think it could be > done, but > > > >not by moi. > > > > > > > >> > Hi: > > > >> > I have two INFORMIX 4GL programs.I want if the first one insert > a > > > >row > > > >> > into the database,the second one can trap this and do some display > on > > > >it's > > > >> > screen.Can I do it with 4GL only,Or I must use C instead. > > > >> > Please Help Me! > > > >> > I'll killed if I can't finished the project this weekend! > > > >> > > > > >> > My email is pangq@zhej.piccnet.com.cn > > > >> > > > > >> > Any and all information is welcome. > > > >> > > > > >> > Thanks, > > > >> > > > > >> > Danny > > > > > > > > > > > >-- > > > >======================================================= > > > >Dennis J. Pimple Informix Software, Inc. > > > >Principal Consultant 6300 S Syracuse Way Ste 205 > > > >dennisp@informix.com Englewood CO 80111 > > > >office: 303-850-0210 > > > >direct: 303-740-5611 Opinions expressed are mine, > > > > fax: 303-779-4025 and do not necessarily > > > > reflect those of my employer. > > > > > > > >http://www.informix.com > > > > > > ------------------------------------------------------------ > > > This e-mail has been sent to you courtesy of OperaMail, as a free > service from > > > Opera Software, makers of the award-winning Web Browser, Opera. Visit > us at > > >