Re: 4GL question
Posted in 2000
Thanks! That worked and is a much better way. (I knew there had to be a better way) Candy -- Candy McCall ONLINE Computing, Inc. (candym@olcinc.com) > Hi Candy, > > Have you tried to use the data type VARCHAR instead of CHAR ? As far > as i know it only allocates the string you assign with no space, so you > don't have to substring the remaining space. > > -------------------------------------------------------------------------- --------------------------------------- > > e.g > main > define > ls_str varchar(4) > > let ls_str = "Test" > call f_one(ls_str) > end main > > > function f_one(ls_str) > define > ls_str varchar(100) > > do something ... > > return ls_str > > end function > > -------------------------------------------------------------------------- ------------------------------------ > > I hope it helps. > > Note: VARCHAR limit is only 255. > > > Jojo > > > > 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) >