Cobol code for displaying the output in the following format



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Sun Jan 31, 2010 10:56 pm

IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I PIC 9.
PROCEDURE DIVISION.
          PERFORM VARYING I FROM 1 BY 1 UNTIL I > 5
                   DISPLAY I WITH NO ADVANCING
          END-PERFORM.
          STOP RUN.


Will this give the output in the following format

1 2 3 4 5

One more doubt

How can i work with cobol programs at home.
I am having window 7 os in my pc.
which cobol compiler should i use.
Where can i download it for free.
Please suggest me a solution for this.
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re: Cobol code for displaying the output in the following format

 

Re: Cobol code for displaying the output in the following format

Postby Robert Sample » Sun Jan 31, 2010 11:15 pm

How can i work with cobol programs at home.
I am having window 7 os in my pc.
which cobol compiler should i use.
Where can i download it for free.
Please suggest me a solution for this.
Google is your friend.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Cobol code for displaying the output in the following format

Postby dick scherrer » Mon Feb 01, 2010 5:16 am

Hello,

Will this give the output in the following format
No. . . And obviously you did not read the informaton about DISPLAY in the COBOL manual. Why would you continue to flail away rather than simply reading the documentation?

If you install Hercules, you can have a "mainframe" on your pc. . .
http://www.hercules-390.org/

I don't know if this will run on Windows 7. Also, before downloading/buying a compiler, make sure this will also run on Windows 7. Lots of things do not. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Mon Feb 01, 2010 7:12 am

Thanks and sorry
I will go through it once again in detail
Thank you very much for your valuable suggestions.
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol code for displaying the output in the following format

Postby dick scherrer » Mon Feb 01, 2010 8:00 am

You're welcome - good luck :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Tue Feb 02, 2010 9:20 pm

Hello,

there are two variables--------var1 and var2
i am taking string in var1-------------var1="hello everybody"
var2 is empty
Now my question is what should be done to get

var1="hello"
var2="everybody"
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol code for displaying the output in the following format

Postby Robert Sample » Tue Feb 02, 2010 9:38 pm

Look at UNSTRING in the COBOL Language Reference manual.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Cobol code for displaying the output in the following format

Postby dick scherrer » Wed Feb 03, 2010 12:47 am

Hello,

Just a hint - if you want part of the result back in var1, move the entire input "string" to a work area before the UNSTRING.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Wed Feb 03, 2010 11:20 pm

Hello ,
Can you explain the hint a little more.
How to move the string to a work area.
what is work area and its importance.
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol code for displaying the output in the following format

Postby Robert Sample » Wed Feb 03, 2010 11:31 pm

A work area is another variable of equal size that is used to hold a copy of the variable. The importance is that UNSTRING destroys the current contents of the receiving variables. Moving variables around is done by ... the MOVE statement.

Terminology note: COBOL does not have strings, which is a concept from C or similar languages. COBOL has variables. Variables can be numeric, numeric edited, alphabetic, alphanumeric, group, national, or DBCS (double-byte character set) -- but not string.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

PreviousNext

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post