trailing spaces in character values on the 4gl stack I'm using 4gl 7.20.UE1.
When popping character values from the stack in a C function I would
dearly love to be able to know exactly what the caller put there,
particularly how many trailing spaces there really were. (I'd also
love to be able to know how big the string was so I wouldn't have to
risk truncating it, or to allocate a too-big buffer for it. I suspect
that if the former can be done this will be doable as well.)
The only way I know of to do something like this is to pass in a
second arg which tells how long the first arg was really supposed to
be. It isn't much of a solution.
4gl reports can manage this trick, their underlying printlist()
function can print out exactly what was put on the stack. Does
anybody know how I can manage this in my own programs? I realize
that if it's possible at all it'll be using undocumented features,
and if that's what it takes I'm resigned to do so.
Here's a demonstration of a 4gl report doing what I'd like to be able
to do myself. The output of this program:
main
start report stack_test to screen
output to report stack_test()
finish report stack_test
end main
report stack_test()
output
top margin 0
bottom margin 0
left margin 0
right margin 8191
page length 1
format on every row
print from_func_1(), "<"
print from_func_2(), "<"
print from_func_3(), "<"
end report
function from_func_1()
define s char(20)
let s = "unclipped string"
return s
end function
function from_func_2()
define s char(20)
let s = "clipped string"
return s clipped
end function
function from_func_3()
return "constant with 1 trailing space "
end function
is this:
unclipped string <
clipped string<
constant with 1 trailing space <
--
Roderick Schertler <taurine@ibcinc.com>
+1-434-963-4034 |