Here comes some sample code including the post before. See the explanations in
COBOL comments what can be improved (click the Quote link for this post to get
the right indentation):
*-----------------------------------------------------------------
* Program PSPSAM showing some stuff for testing COBOL lexers
* (especially old errors in PSPad COBOL syntax)
*-----------------------------------------------------------------
IDENFTIFICATION DIVISION.
PROGRAM-ID. 'PSPSAM'.
*-----------------------------------------------------------------
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SYSERR IS MY-ERR
DECIMAL-POINT IS COMMA.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MY-FILE ASSIGN TO MY-FILE-NAME
ORGANIZATION IS LINE SEQUENTIAL
FILE STATUS IS MY-FILE-STATUS.
SELECT MY-INPFILE ASSIGN TO "INPUT.DAT"
ORGANIZATION IS SEQUENTIAL
FILE STATUS IS MY-FILE-STATUS.
I-O-CONTROL.
DATA DIVISION.
FILE SECTION.
FD MY-FILE.
01 MY-FILE-REC.
02 MY-REC.
03 MY-BIG1 PIC X(32000).
03 MY-BIG2 PIC X(32000).
FD MY-INPFILE.
01 MY-INPFILE-REC.
02 MY-INPREC PIC X(320).
*-----------------------------------------------------------------
WORKING-STORAGE SECTION.
78 MY-FILE-NAME VALUE 'TEST.DAT'.
77 MY-FILE-STATUS PIC X(02).
01 PARM-1.
05 PARM-1-1 PIC X(12).
05 PARM-1-2 PIC X(10).
01 PARM-2 PIC X(80).
COPY WSCPY.
* BASED/ALLOCATE not in PSPad's keywords:
77 BVAR PIC X(650000) BASED.
*-----------------------------------------------------------------
* LOCAL-STORAGE is marked while WORKING-STORAGE is not because
* LOCAL-STORAGE is missing in PSPad's keywords
LOCAL-STORAGE SECTION.
* This var is marked:
01 local-var pic 9 value zero.
88 local-var-unchanged value zero.
* This var is NOT marked (because of two spaces):
* Either all these vars should be marked or none
01 loc2 PIC X(12) VALUE SPACES.
77 loc3 pic 9(05) usage comp-3 value 12.
*-----------------------------------------------------------------
LINKAGE SECTION.
01 some-rec.
02 some-rec-1 pic 9(04).
02 some-rec-2 pic x(4096).
*-----------------------------------------------------------------
PROCEDURE DIVISION USING some-rec.
declaratives.
* Error section for MY-FILE:
DEC-MY SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON MY-FILE.
DM-BEG.
display 'ERROR IN MYFILE: "' MY-FILE-STATUS '"'
* end-display missing in keywords (and not shown as belonging
* to the display, see some2 section for explanation)
end-display
accept loc2
end-accept
* returning missing in keywords
exit program returning 1
DM-END.
EXIT SECTION.
* Error section for all files opened with INPUT:
DEC-MYIN SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON INPUT.
DMI-BEG.
display 'ERROR IN MYINPFILE: "' MY-FILE-STATUS '"'
end-display
accept loc2
end-accept
exit program returning 1
DMI-END.
EXIT SECTION.
end declaratives.
*-----------------------------------------------------------------
MAIN SECTION.
PARA-1.
OPEN INPUT MYINPFILE
READ MYINP-REC END-READ
OPEN OUTPUT MYFILE
perform 2 times
write MYFILE from myinp-rec
end-write
end-perform
CLOSE MYFILE
CLOSE MYINPFILE
ALLOCATE BVAR
MOVE ALL 'A' TO BVAR
CALL 'SUBMOD' USING PARM-1
BVAR
* This is a one-word-line with a dot afterwards,
* not a paragraph.
* DIVISIONs, SECTIONs, paragraphs, FD/SD and lvl 01/77 entries
* have to start in Area A --> columns 8 to 11)
PARM-2.
FREE ADDRESS OF BVAR
* This is simply a normal one-word-command with a dot afterwards,
* Not a paragraph:
continue.
PARA-2.
EXIT PROGRAM.
*-----------------------------------------------------------------
SOME SECTION.
move PARM-1 to PARM-2
* EXIT written uppercase - all fine in Code-Explorer
EXIT SECTION.
*-----------------------------------------------------------------
SOME2 SECTION.
if 1 = 1
CANCEL 'SUBMOD'
* Only if/end-if are shown as belonging together
* (both are highlighted if the cursor is in one of them).
* Can the else be highlighted there, too?
else
continue
end-if
*
evaluate true
* Only evaluate/end-wevaluate are shown as belonging together
* (both are highlighted if the cursor is in one of them).
* Can all when be highlighted there, too?
when 1 = 1
continue
when 0 = 0
continue
end-evaluate
*
* exit written lowercase - shown as a new section
* in Code-Explorer
exit SECTION.
*-----------------------------------------------------------------
* It would be nice to have a list of all used copies in
* Code-Explorer like it is avaliable for includes in C-Syntax.
* Copies can occur EVERYWHERE in the source.
* They can have different ways of naming:
* Without anything (most compilers will look for PDCPY.CBL, then
* PDCPY.CPY, then PDCPY in this case)
COPY PDCPY.
* As literal with/without full name
COPY "PDCPY2.CPY".
COPY "C:\COBOL\CPY\PDCPY2.CPY".
* With IN clause:
COPY "PDCPY3.CPY" IN "C:\COBOL\CPY".
* With al lot of clauses:
COPY PDCPY4
IN CPYBIB
SUPPRESS PRINTING
REPLACING ==SOMETEXT== BY ==SOME OTHER TEXT==
LEADING ==AA-== BY ==PSPSAM==.
*-----------------------------------------------------------------
*--- End of program PSPSAM ---------------------------------------
Thank you for having a look at this.
human
--
<http://forum.pspad.com/read.php?6,54269,54836>
PSPad freeware editor http://www.pspad.com