From: John R. C. <jo...@we...> - 2006-04-02 22:59:41
|
On Sunday 02 April 2006 11:24, Marion C. Magee wrote: > Try putting '100-MAIN. ' right below the line 'PROCEDURE DIVISION'. > Then remove the '.' at the end of the DISPLAY line > > **Program Listing** > > IDENTIFICATION DIVISION. > PROGRAM-ID. HELLO. > ENVIRONMENT DIVISION. > DATA DIVISION. > PROCEDURE DIVISION. > 100-MAIN. > DISPLAY "HELLO WORLD" > STOP RUN. > > **End Listing** > > Marion C. Magee > Student/ECU > ma...@cs... > 580-421-9681 > > Fred Mobach wrote: > > On Friday 31 March 2006 06:50, Dilsia A. Martinez wrote: > >> Dear TinyCOBOL Users: > >> > >> I've rewritten the program hello world but now it > >> gives me the following error: > >> > >> C:\TinyCOBOL>htcobol hello.cob > >> hello.cob: 6: error: syntax error on or before '.' > >> hello.cob 6: error: unknown or wrong statement, > >> on or before '.' > >> > >> > >> My program is written as follows: > >> > >> IDENTIFICATION DIVISION. > >> PROGRAM-ID. HELLO. > >> DATA DIVISION. > >> PROCEDURE DIVISION. > >> DISPLAY 'HELLO WORLD'. > >> STOP RUN. > > > > I don't know if it is nowadays still important but in the old days the > > COBOL syntax requested the proper usage of margins. In case it is still > > important you might prefix the lines with DISPLAY and STOP with four > > space characters. > I agree with the need for at leat one paragraph header in the PROCEDURE DIVISION. I don't agree with removing the period. It should work either way. I agree with the need for more indentation for non-header lines. The rules on the modern format are a bit confusing to me so I always use the old format (sometimes with line numbers!) I start headers, level 01, and level 77 in column 8 and everything else in column 12 or more. Your program with additional space works with Tiny Cobol and Open Cobol on my Slackware Linux system: IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. PROCEDURE DIVISION. DISPLAY 'HELLO WORLD'. STOP RUN. Now it really shouldn't. The version below is more traditional and hence safer: IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. MAIN-ROUTINE. DISPLAY 'HELLO WORLD'. STOP RUN. To avoid stupid mistakes I always start off with a copy of my "template.cbl" program and then add code to it: 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEMPLATE. 000030 AUTHOR. JOHN CULLETON. 000040 INSTALLATION. WEXFORDPRESS 000045 Eldersburg MD. 000050*REMARKS. 000060* THIS IS A TEMPLATE FOR OPEN COBOL AND HTCOBOL. 000070 ENVIRONMENT DIVISION. 000080 000090 CONFIGURATION SECTION. 000100 SOURCE-COMPUTER. 000110 Linux. 000120 OBJECT-COMPUTER. 000230 Linux. 000140 000150 INPUT-OUTPUT SECTION. 000160 FILE-CONTROL. 000170 SELECT PRINTFILE ASSIGN TO PRINTER. 000180 DATA DIVISION. 000190 000200 FILE SECTION. 000210 000220 WORKING-STORAGE SECTION. 000230 000240 PROCEDURE DIVISION. 000250 001-MAIN-PROCEDURE. 000260 DISPLAY "TEMPLATE". 000270 STOP RUN. -- John Culleton COBOL since 1968. |