On 10/30/2012 8:34 PM, Jack Tucky wrote:
Thanks Luis and Joe. I tried the varchar thing but the data was overlapping
for some reason ( I wasn't clearing it perhaps). The %trimr worked.

If you use a varying field, you have to pass the address of the data portion of the field.

If you just code %addr(varchar), the write() API would receive the first two bytes of the varying field which contain a the current length of the field.

If VARCHAR = 'abc', the hex value is x'0003818283'. If you then coded
write(fd : %addr(varchar) : %len(varchar))
the API would write x'000381' rather than x'818283' which you want.

Coding this will work:
write(fd : %addr(varchar:*data) : %len(varchar))

I wouldn't use a varying field for this if my data was already in a fixed length field. But if your data was already in a varying length field, %addr(varfld: *data) is the way to go.

Requires v6r1 RPG. If you don't have V6R1, use
%addr(varfld) + 2

This thread ...

Return to Archive home page | Return to MIDRANGE.COM home page