A word about matching pairs of begin/end fold keywords: Commands like 'IF' can be terminated with the matching end keyword (i.e. 'END-IF') or by a period ('.'). Since there is no line continuation character, a command like 'DISPLAY' which has no matching end keyword can span multiple lines and, if possible, should be folded when it does.
Local variables are declared in the 'WORKING-STORAGE SECTION' and are defined using 'level numbers' (e.g. 01, 02, etc.). Lines that contain these level numbers should be folded to the next line containing a level number of the same value (unless the next level number is greater than the current level number).
Since COBOL is column sensitive, any line that contains either of the words 'DIVISION' or 'SECTION', can be folded to the next line that begins in column 8 and contains either of the words 'DIVISION' or 'SECTION' (respectively). Any line that begins in column 8 and does NOT contain either of the words 'DIVISION' or 'SECTION' can be folded to the next line that begins in column 8 and does NOT contain either of the words 'DIVISION' or 'SECTION'.
Extension: .COB
Line Comment: * (column 7 only)
Block Comment: none
Begin: IF
End: END-IF (or '.')
Begin: PERFORM
End: END-PERFORM (or '.')
Begin: EVALUATE
End: END-EVALUATE (or '.')
Sample Code:
Code: Select all
IDENTIFICATION DIVISION.
PROGRAM-ID. PD254C.
*-------------------------------------------
*-------------------------------------------
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-PC.
OBJECT-COMPUTER. IBM-PC.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
FILE SECTION.
*-------------------------------------------
WORKING-STORAGE SECTION.
01 NUMBER-OF-PARAMETERS PIC 99 COMP-1.
*-------------------------------------------
COPY "BTRLIB.COB".
COPY "RCI711LB.COB".
COPY "RCI800LB.COB".
COPY "RCI598LB.COB".
COPY "PD700HLP.COB".
COPY "PD520LIB.COB".
*-------------------------------------------
01 WORK-AREA.
02 PROJECT-NO-WS PIC X(200).
01 KI-AREA.
02 PROJECT-NAME-KI PIC X(30).
*-------------------------------------------
LINKAGE SECTION.
01 PROJECT-NO-PARAM USAGE HANDLE.
*-------------------------------------------
PROCEDURE DIVISION USING PROJECT-NO-PARAM.
*-------------------------------------------
MAIN-LINE.
CALL 'C$NARG' USING NUMBER-OF-PARAMETERS.
IF NUMBER-OF-PARAMETERS < 1
GO TO EOJ
END-IF.
CALL 'C$GETVARIANT' USING PROJECT-NO-PARAM,
PROJECT-NO-WS.
CALL 'PD253.CBX' USING PROJECT-NO-WS.
CALL 'PD253.CBX'.
CANCEL 'PD253.CBX'.
EOJ.
GOBACK.
*-------------------------------------------