I'm just 'assuming' this is a bug although it seems rather unusual to be one at this stage.
I'm testing a datafield to see if the first character on the line (after possible spaces) is a '('.
ie:
IF TRIM(FIELD(1:1)) = "(" MOVE 1 TO COUNTA
This always seems to fail - even when I display the contents of field immediately before the test and it shows bbb(xxxx b=blank x=other characters.
In fact if I DISPLAY TRIM(FIELD) then I get what I want - (xxxxx - So - surely it should work.
However: If I change the code to the following it all works fine.
MOVE TRIM(FIELD) TO FIELD.
IF FIELD(1:1) = "(" MOVE 1 TO COUNTA
Am I correct in assuming that the Trim statement has failed - or is it the If ??.
Thanks
and all is fine?
Thanks - strange it didn't give any compiler warnings (even with -Wall).
I think I've seen something like this with IBM COBOL for zOS. Reference Modification has to be done last, so...
IF TRIM(FIELD)(1:1) = "(" would be correct, but
IF TRIM(FIELD(1:1)) = "(" would not be correct. You would be trying to TRIM a one-byte field.
Last edit: Simon Sobisch 2019-05-16
Why should the compiler even spill out a warning? TRIM from a one-byte field is perfectly fine (and depending on the std you use it could possibly result in either a one byte field or a zero-length field (when it only includes spaces)).