Re: 4GL question
Posted in 2000
Candy McCall wrote: > I'm wanting to write a somewhat generic 4gl function that will > return a character string that could anywhere from 1 to 64 > characters. I want to pass the number of characters in the > resulting string to the function. It's use would be > something like the following: > MAIN > DEFINE > result2 CHAR(2), > result4 CHAR(4), > result8 CHAR(8), > result16 CHAR(16) > > CALL some_function(2) RETURNING result2 > CALL some_function(4) RETURNING result4 > CALL some_function(8) RETURNING result8 > CALL some_function(16) RETURNING result16 > END MAIN > FUNCTION some_function(nchar) > DEFINE nchar SMALLINT, > result CHAR(64) > > .......some code.... > > RETURN result[1,nchar] > END FUNCTION > Do you see any problem with this or know > of a better way to return a variable length > string? > Thanks in advance! > Candy > -- > Candy McCall > ONLINE Computing, Inc. > (candym@olcinc.com) You can use the function LENGTH(result) which would return the size of your string. If you are using a CHAR then make sure that you have CLIPPED the result before you put it through the LENGTH function. Basically you can say LET nchar = LENGTH(result) Hope this helps. -- Compliments of QueriX -------------------------------------------------------------------------------------------------- QueriX 4GL Compilers are Informix 4GL Compatible, and Connection to other RDBMS such as Oracle. Hydra 4GL Compiler (Compatible with I4GL) Compile once, run everywhere Phoenix Windows GUI. (Front End to 4GL) Chimera Java GUI The only GUI you will ever need... (Front End to 4GL) Arachne Web Technology (Front End to 4GL on the Web & HTML Report Generator) ESQL/C Compiler For more details visit: http://www.querix.com/ ---------------------------------------------------------------------------------------------------