In Cobol, to test “null or empty” we use “NOT = SPACE [ AND/OR ] LOW-VALUE” ? Which is it?

后端 未结 4 1868
名媛妹妹
名媛妹妹 2021-02-20 02:22

I am now working in mainframe, in some modules, to test

Not null or Empty

we see : NOT = SPACE OR LOW-VALUE The chief

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-20 03:08

    I agree with NealB. Keep it simple, avoid "short cuts", make it easy to understand without having to refer to the manual to check things out.

    IF ( X EQUAL TO SPACE ) 
    OR ( X EQUAL TO LOW-VALUES )
       CONTINUE
    ELSE
       do whatever...
    END-IF
    

    However, why not put an 88 on X, and keep it really simple?:

    88  X-HAS-A-VALUE-INDICATING-NULL-OR-EMPTY VALUE SPACE, LOW-VALUES.
    
    IF X-HAS-A-VALUE-INDICATING-NULL-OR-EMPTY
        CONTINUE
    ELSE
       do whatever...
    END-IF
    

    Note, in Mainframe Cobol, NULL is very restricted in meaning, and is not the meaning that you are attributing to it, Tom. "Empty" only means something in a particular coder-generated context (it means nothing to Cobol as far as a field is concerned).

    We don't have "strings". Therefore, we don't have "null strings" (a string of length one including string-terminator). We don't have strings, so a field always has a value, so it can never be "empty" other than as termed by the programmer.

    Oguz, I think your post illustrates how complex something that is really simple can be made, and how that can lead to errors. Can you test your conditions, please?

提交回复
热议问题