Key Takeaways: Pointer and Reference Modification

  1. Reference modification identifier(start:length) provides byte-level access to any alphanumeric data item. Position 1 is the leftmost byte. Both start and length can be arithmetic expressions for dynamic access.

  2. Omitting the length in reference modification (identifier(start:)) takes everything from the starting position to the end of the item — useful when you don't know or need the remaining length.

  3. LENGTH OF returns the allocated byte length of a data item. Use it to validate reference modification boundaries: always check that start + length - 1 <= LENGTH OF target.

  4. FUNCTION LENGTH works like LENGTH OF but can also be applied to literals and used more naturally in arithmetic expressions.

  5. The pointer build pattern — maintaining a position variable and appending pieces via reference modification — is the standard COBOL idiom for constructing dynamic output strings. Initialize the pointer to 1, advance it by the length of each appended piece.

  6. STRING/UNSTRING WITH POINTER extends built-in string operations with incremental processing, allowing multiple operations to build/parse a single string without restarting from position 1.

  7. Parsing without UNSTRING using reference modification provides finer control for complex formats: variable delimiters, quoted fields, nested structures, and right-to-left scanning.

  8. ADDRESS OF and POINTER data items provide memory-level access for inter-language calls and dynamic buffer processing. Use SET (not MOVE) for pointer operations. Reserve pointers for cases where reference modification is insufficient.

  9. Defensive programming is essential: Reference modification does NOT generate boundary checks by default. Enable SSRANGE during development and always validate position/length values before dynamic reference modification.

  10. The Modernization Spectrum: Reference modification bridges COBOL's fixed-format heritage with modern variable-format data (EDI, CSV, delimited formats). These techniques extend COBOL's capabilities without replacing its strengths.