[go: up one dir, main page]

Menu

#574 If test on trimmed partial field seems to fail.

invalid
not-our-bug
nobody
None
5 - default
2019-05-16
2019-05-14
David Wall
No

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

Related

Bugs: #574

Discussion

  • Simon Sobisch

    Simon Sobisch - 2019-05-14
    -IF TRIM(FIELD(1:1)) = "(" MOVE 1 TO COUNTA.
    -IF TRIM(FIELD)(1:1) = "(" MOVE 1 TO COUNTA.
    

    and all is fine?

     
  • David Wall

    David Wall - 2019-05-14

    Thanks - strange it didn't give any compiler warnings (even with -Wall).

     
  • Arnold Trembley

    Arnold Trembley - 2019-05-15

    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.

     
  • Simon Sobisch

    Simon Sobisch - 2019-05-16
    • status: open --> not-our-bug
    • Group: GC 3.0 --> invalid
     

    Last edit: Simon Sobisch 2019-05-16
  • Simon Sobisch

    Simon Sobisch - 2019-05-16

    Simon S pointed out the same & that's sorted it - however - I did try to get the Compiler to produce some sort of error message regarding this - but to no avail.

    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)).

     

Log in to post a comment.