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

后端 未结 4 1864
名媛妹妹
名媛妹妹 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:14

    In COBOL, there is no such thing as a Java null AND it is never "empty".

    For example, take a field

     05  FIELD-1  PIC X(5).
    

    The field will always contain something.

    MOVE LOW-VALUES TO FIELD-1.
    

    now it contains hexadimal zeros. x'0000000000'

    MOVE HIGH-VALUES TO FIELD-1.
    

    Now it contains all binary ones: x'FFFFFFFFFF'

    MOVE SPACES TO FIELD-1.
    

    Now each byte is a space. x'4040404040'

    Once you declare a field, it points to a certain area in memory. That memory area must be set to something, even if you never modify it, it still will have what ever garbage it had before the program was loaded. Unless you initialize it.

    05  FIELD-1 PIC X(6) VALUE 'BARUCH'.
    

提交回复
热议问题