Re: HELP! C routines & 4gl
Posted in 1997
In article <33B7C0CC.5FCD@cam.org>, acvis@cam.org wrote: > > Does anyone know of a clever, efficient way of returning multiple rows > from a C routine to a calling 4gl program? We need to send one set of > arguments from the 4gl program to the C routine. The C routine may send > back from 0 to several rows of data. Any suggestions? You need 2 C routines, one to initialize and the other to return data one row at a time. If the C routine can determine the total number of rows beforehand, then the 4gl stub could look something like: call c_init(arg1,arg2,arg3...) returning num_rows for i = 1 to num_rows call c_get_row() returning one_row -- deal with the row here end for Otherwise, if the number of rows isn't determined until all the rows have been dealt with, then maybe this kind of structure would be convenient: call c_first_row(arg1,arg2,arg3...) returning success, one_row while success -- deal with the row here call c_next_row() returning success, one_row end while The 2 C functions must be in the same module and use static variables, e.g. declared outside of the functions. Hope this helps, ---------------------------------------------------------------------- John H. Frantz Power-4gl: Extending Informix-4gl frantz@centrum.is http://www.rl.is/~john/pow4gl.html -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet