Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

hello world doesn't work
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?

Report this thread to moderator Post Follow-up to this message
Old Post
Cydrome Leader
09-26-05 08:55 AM


Re: hello world doesn't work
> 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.


Report this thread to moderator Post Follow-up to this message
Old Post
Richard
09-26-05 08:55 AM


Re: hello world doesn't work
Richard <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.

Report this thread to moderator Post Follow-up to this message
Old Post
Cydrome Leader
09-26-05 08:55 AM


Re: hello world doesn't work
"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.

Report this thread to moderator Post Follow-up to this message
Old Post
Volker
09-26-05 08:55 AM


Re: hello world doesn't work
The 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


Report this thread to moderator Post Follow-up to this message
Old Post
Richard
09-26-05 08:55 AM


Re: hello world doesn't work
Volker <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.

Report this thread to moderator Post Follow-up to this message
Old Post
Cydrome Leader
09-26-05 08:55 AM


Re: hello world doesn't work
Cydrome 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

Report this thread to moderator Post Follow-up to this message
Old Post
John Culleton
09-26-05 11:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:09 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.