Code Comments
Programming Forum and web based access to our favorite programming groups.I'm trying this hello world program with OpenCOBOL 0.31 * Sample COBOL program IDENTIFICATION DIVISION. PROGRAM-ID. hello. PROCEDURE DIVISION. DISPLAY "Hello World!". STOP RUN. and trying to compile with: [host]user:~/cobol$ cobc hello.cob and get: hello.cob:1: warning: invalid indicator 'l' at column 7 hello.cob:1: syntax error, unexpected WORD, expecting IDENTIFICATION What does any of this mean, and what's wrong here?
Post Follow-up to this message> OpenCOBOL 0.31 Standard ANS'85 Cobol programs are laid out as follows: Columns 1-6 Sequence number, may be left blank Column 7 Indicator column, may have a value of: * - line is a comment - - line is a continuation D - line is a 'debugging line' Columns 8-11 Area A Columns 12-72 Area B Certain things need to, or can, start in Area A such as labels, and other things, such as statements, need to start in Area B. Some Cobol systems have extensions that allow frre format source, OpenCobol does not. Adjust your program to the correct layout and it will get over that particular problem. You will note that it is complaining about the 'l' of 'sample' because this is in Column 7.
Post Follow-up to this messageRichard <riplin@azonic.co.nz> wrote: > > Standard ANS'85 Cobol programs are laid out as follows: > > Columns 1-6 Sequence number, may be left blank > > Column 7 Indicator column, may have a value of: > * - line is a comment > - - line is a continuation > D - line is a 'debugging line' > > Columns 8-11 Area A > Columns 12-72 Area B > > Certain things need to, or can, start in Area A such as labels, and > other things, such as statements, need to start in Area B. > > Some Cobol systems have extensions that allow frre format source, > OpenCobol does not. > > Adjust your program to the correct layout and it will get over that > particular problem. > > You will note that it is complaining about the 'l' of 'sample' because > this is in Column 7. > I don't know know enough about what each line is to know where they belong. How would you format this program? I can only get it to compile if all text starts on column 7. The program won't print anything when run though. Moving anyting over past column 7 = won't compile.
Post Follow-up to this message"Cydrome Leader" wrote: > Richard <riplin@azonic.co.nz> wrote: 12345678901234567890... * Sample COBOL program IDENTIFICATION DIVISION. PROGRAM-ID. hello. PROCEDURE DIVISION. DISPLAY "Hello World!". STOP RUN. V.
Post Follow-up to this messageThe asterisk goes in colum 7 Headers and labels start in column 8. Statements (DISPLAY, STOP) start in column 12. * Sample COBOL program <- * in 7 IDENTIFICATION DIVISION. <- I in 8 PROGRAM-ID. hello. <- P in 8 PROCEDURE DIVISION. <- P in 8 DISPLAY "Hello World!". <- D in 12 STOP RUN. <- S in 12 > Moving anyting over past column 7 = won't compile. Do not use tab characters. It may be that your editor is noticing that colsumn 1-7 are spaces and putting a single tab character instead of the spaces. Get a better editor. Alternately put sequence numbers in columns 1-6. ie 000010 for the first line 000020 for the second line etc. This is not needed by Cobol but may be required to stop your editor munting the code by using tabs. The code does compile and run correctly when in the correct format. The compile command is: cobc -fmain hello.cbl
Post Follow-up to this messageVolker <3845634746@despammed.com> wrote: > "Cydrome Leader" wrote: > > 12345678901234567890... > * Sample COBOL program > IDENTIFICATION DIVISION. > PROGRAM-ID. hello. > PROCEDURE DIVISION. > DISPLAY "Hello World!". > STOP RUN. > > V. This works fine. I suspect I did have a tab after moving text around. I'm fascinated by the BASIC/foxpro like syntax. Perl disgusts me so I guess this is the language for me learn.
Post Follow-up to this messageCydrome Leader wrote: > Volker <3845634746@despammed.com> wrote: > > This works fine. I suspect I did have a tab after moving text around. I'm > fascinated by the BASIC/foxpro like syntax. Perl disgusts me so I guess > this is the language for me learn. I suggest that you use a programmer' editor such as Gvim. If you specify syntax checking and subequently you get things in the wrong column then the editor will color the entire line in red with white print. Also I suggest you borrow get a good college text on COBOL. Or look in the manuals that come with a commercial version. I learned COBOL (and FORTRAN and PL/I) from the self teaching booklets from IBM, the famous "Green Books. Don't think they are around any more. One trick: Even though line numbers are no longer required I alwasy start off from scratch with the folLlowing statements: 123456 IDENTIFICATION DIVISION. 123456 PROGRAM-ID. This gives a visual guide to the correct placement of things. Or better, start off with a tamplate program. Just copy the file below that I call "template.cbl" to another file name. Then expand the copy. ---------------------------------------------------------------- 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 Able Indexers and Typesetters
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.