Menu

Where in the prog guide is [dataname(1:15)] explained?

2023-10-14
2023-10-14
  • Michael F Gleason

    Some time ago, I found a program that had this type of code;

    MOVE WS-ITEM (1 : 15) TO WS-SEARCH-KEY (16 :)
    IF WS-ITEM (WS-POSITION : WS-LENGTH) EQUAL "ABC"
    

    I understand what and how to use this definition, but can't find it in the manual.

    The move will move the 1st 15 bytes of WS-ITEM to WS-SEARCH-KEY and space fill. See, I understand, but I don't know what it is called. Not index or subscript.

    It drives me nuts that I can't find the documentation on this definition. I have been using this a lot lately. It beats the heck out of defining tables with OCCURS clauses.

    Any body know?

    Michael :-)

     

    Last edit: Simon Sobisch 2023-10-14
    • Ralph Linkletter

      Reference modification

       
      👍
      1
      • Arnold Trembley

        Arnold Trembley - 2023-10-14

        See Section 2.2.3 "Reference Modifiers" in the GnuCOBOL 3.2 Programmer's Reference Manual.

         
        ❤️
        1
  • Michael F Gleason

    Thanks Ralph

     
  • Simon Sobisch

    Simon Sobisch - 2023-10-14

    Thanks Ralph and Arnold for the right answer to the "main question".

    For the "rest"... Note that it does not necessarily MOVE the first 15 bytes of the field.
    It moves the first 15 characters starting at the beginning from the source field to the character position 16 of the target field, then truncate/space-fill it as necessary.

    Only if both fields refer to an alphanumeric items (all groups that don't have an explicit USAGE are alphanumeric, too) or numeric-edited items or numeric items of USAGE DISPLAY, then those character positions match to bytes.
    Also keep in mind that, depending on the compiler used and the generated/enabled runtime checks, the reference-modification may also be out of bounds and include bytes from the fields "afterwards" (if that is outside of a level 01/77, then you are highly in trouble for migrations).

     
  • Michael F Gleason

    Thanks Simon for the clarification on BYTES vs CHARACTERS.

    Anyone reading my posts, documentation notes need to understand what I meant VS what I typed.

    Sometimes my brain is someplace else. It (my brain) generally operated in 8-bit mode with a small memory size.

    Michael :-)

     

Anonymous
Anonymous

Add attachments
Cancel