Module 6: Procedure Division
MOVE: reference modification
- This is special purpose option and can be used to move partially selected content of sending field to the receiving field
- In COBOL-85, it is possible to refer part of a data field by mentioning the leftmost character position and length.
- For example, assume below data declaration
05 BOOK-NAME PIC X(12) VALUE “IBMMAINFRAME”.Now below statement coded in PROCEDURE DIVISON,wll transfer the value “MAINFR” to CODE-NAME. Here, BOOK-NAME(4: 6) is used to refer 6 consecutive characters staring from the position 4(from left) within BOOK-NAMEMOVE BOOK-NAME(4: 6) TO CODE-NAME
- Basic syntax:-
identifier (position : [length] )
- Length is optional to specify and when omitted, all the remaining characters of the identifier will be considered for operation. For example, MOVE BOOK-NAME(4: ) TO CODE-NAME will transfer the value “MAINFRAME ” to CODE-NAME.
- It is mandatory to have a space after the delimiter colon (:).
- The position and length can be literal/identifier/arithmetic-expression.
- identifier filed can be of any data type, but should have DISPLAY usage