Re: Informix C-compiler Version does not initialize variables?
Posted in 1995
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
pinoy_ako (john@gagme.wwa.com) wrote: : Hello, : We've go a program fragment like this: (clipped to minimum so : syntax isn't correct) : FUNCTION hello(var1, var2, var3) : ... : DEFINE var3 like sometable.somecol : . : . : IF var3 IS NULL THEN : # do this thing : ELSE : # do another thing : END IF : The function is called like this: : CALL hello(param1, param2, param3) : The problem occurs when param3 is not set to any value (only defined : like this 'DEFINE param3 CHAR(5)', no param3 = "" or initialize param3 : to null or param3 = "value"). THe program goes into the 'do other : thing' part instead of the 'do this thing'. I tried adding this code : to the function hello, above the IF statement so that I can trace : the variable var3 is being set to: : ERROR "this is var3: ", var3 : It showed me the following everytime I ran it: : this is var3: >`@ : There is something wrong here bec. this code worked on c4gl version : 4 4gl on AT&T Unix SysV3.2 with version 4 SE. Now that we : have version 4.12 4gl, C-compiler version on SCO unix 3.2.4 with : 5.02 SE, it just doesn't initialize the variable correctly. Can any : one suggest a solution? I can't just initialize var3 to NULL because : param3 might have a value. This is what I have already tried (but : failed) : IF var3 IS NULL OR var3 = ">`@" THEN ... : Pls. email your thoughts/solutions. Thanks! : John : -- : - J - Hi John, Why dont you try this: IF LENGTH(var3) = 0 OR var3 IS NULL THEN CALL do_this() I dont know when, but i recall a similar problem I had a couple of years ago and checking if it is NULL just dosent do the trick. I hope this works for you! Eric erics@winternet.com