Re: I need to know about types in the stack...
Posted in 1994
In article <2ofv0n$1o3@infmx.informix.com> aland@informix.com (Colonel Panic) writes: >In article <2nv0iq$2b7n@mtecv2.mty.itesm.mx> jvalero@mtecv2.mty.itesm.mx writes: >>I am using 4gl informix linked with C and from there - C - I am trying to read data from stack. >> >>I was wondering how and where the type of these values (in the stack) can be found. >> >>Example: >> CALL Mathx(50, 'A', 2.2) >> Where: >> 50 is short >> A is char >> 2.2 is double >> >>if later I want to read these values from the stack, how can I know the type of these values? > >You could start with RTFM... pages 2-64R et al. It's easiest if you know >the datatypes, then just use the appropriate popping functions, e.g. > popdub(&v3); > popquote(v2,len); > popshort(&v1); > >If you don't know the data types, you can peek into the value structure >and check the v_type field, and handle accordingly. Alan my friend, if only we could. One could write incredibly useful (and actually semi-polymorphic) fgl/c functions if only Informix would expose an API to the stack. There is no documented way to peek into the stack. I requested (really pleaded and even wrote) this very thing prior to the latest release of 4GL but alas, the powers that be said "NO!". Therefore for truly generic functions we either pop() everything as char data (inefficient and not really a complete solution), or we use something like format strings ala printf(). Except in our usage the format string is the last argument to the function instead of the first so that it can be popped first and then the format strings' contents used to control the popping of the rest of the arguments. (efficient but ugly) Of course a clever programmer with all of the major products installed and with a long look at certain published header files and a few greps with the output of "nm" could figure it all out. Scott