COBOL Newbie requires help displaying data read from a file



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

COBOL Newbie requires help displaying data read from a file

Postby torrind » Sun May 10, 2020 12:24 am

Hi All,

My first time here! :-)

I'm a student seconded to a Large bank in the UK as part of my course and I'm learning COBOL in my spare time (GNU COBOL). As a project, I'm writing a simple airline booking program and have got quite far. The help I need now is as follows:

If I have a 100 seater aeroplane setup as 4 rows of 25 seats, I want to be able to read the seat numbers in from a file and display where they are booked on a grid as per the following example:

row1: xxxxxxxxx*xxxxx*xxxxxxx*x
row2: xxxxxxxxxxxxxxxxxxxxxxxxx

row3: xxxxxxxxxxxxxxxx**xxxxxxx
row4: xxxxxxxxxx*xxxxxxxxxxxxx*

In this example row 1 shows seats 10, 16 and 24 as booked
row 3 - seats 67 & 68 are booked
row 4 - seats 86 & 100 are booked (x's are empty seats)

Can anyone help with a simple way of doing this? I've been at this for weeks with no real success.

Thanks in advance,

Darren
torrind
 
Posts: 2
Joined: Sun May 10, 2020 12:18 am
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL Newbie requires help displaying data read from a f

Postby dneufarth » Sun May 10, 2020 8:20 am

Hint = ARRAY
dneufarth
 
Posts: 23
Joined: Thu Oct 15, 2009 2:50 am
Has thanked: 1 time
Been thanked: 2 times

Re: COBOL Newbie requires help displaying data read from a f

Postby Robert Sample » Sun May 10, 2020 2:44 pm

If you have been working on this for weeks, either you need to learn more COBOL or you need to acknowledge that programming is not for you.

Define a variable PIC X OCCURS 100. Initialize all 100 table elements to x. Loop reading the input file and for each input set that element value to asterisk. Loop through table, displaying 25 elements each time.

Or define a 100-byte variable PIC X value all X and use reference modification to change values as input is read. Display 25 bytes at a time.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: COBOL Newbie requires help displaying data read from a f

Postby enrico-sorichetti » Sun May 10, 2020 3:22 pm

where are You facing problems, the logic or the coding ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: COBOL Newbie requires help displaying data read from a f

Postby Robert Sample » Tue May 12, 2020 7:25 pm

Can anyone help with a simple way of doing this? I've been at this for weeks with no real success.
We provide assistance on this forum -- we don't write code for you. And if you want help, you need to post what you're having problems with as well as the code you're having trouble with (using the Code button to preserve spacing).

Your problem is trivial -- I coded it in COBOL in 20 minutes (total) doing it with an array as well as with reference modification.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: COBOL Newbie requires help displaying data read from a f

Postby torrind » Tue May 12, 2020 11:38 pm

Firstly, I wasn't expecting anyone to write the code for me and I thought that I had posted enough info for help which TBH I've not yet received. Typical for programmers (with no social skills) all I've received are number of piss-taking comments about my coding ability which to be honest are not helpful.

So its a trivial problem which you coded in 20 mins - good for you! Things are always easier when you know what you're doing.

I will probably take me 20 months to solve as I've decided not to rely on this unhelpful forum - I'll eventually do it on my own.

Not that you'll care, but thanks for nothing.
torrind
 
Posts: 2
Joined: Sun May 10, 2020 12:18 am
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL Newbie requires help displaying data read from a f

Postby Robert Sample » Tue May 12, 2020 11:47 pm

I had posted enough info for help which TBH I've not yet received
How is this not help?
Hint = ARRAY
Define a variable PIC X OCCURS 100. Initialize all 100 table elements to x. Loop reading the input file and for each input set that element value to asterisk. Loop through table, displaying 25 elements each time.

Or define a 100-byte variable PIC X value all X and use reference modification to change values as input is read. Display 25 bytes at a time.
I told you not one, but TWO different ways to code the problem. It is NOT our fault if you didn't bother to tell us what the specifics of the problem(s) you're having -- you didn't respond to the question about if you're having problems with the logic or the coding, for example. We gave you plenty of help AT THE LEVEL YOU ASKED THE QUESTION -- if you wanted different help, you should have asked something different.

Not that you'll care, but thanks for nothing.
Well, on this as every forum, you get back proportionate to what you put in. You gave us nothing, you got nothing, and you complained bitterly about it. It's probably good you've decided not to ask more questions since with that attitude your chances of getting help with any further questions is extremely small.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: COBOL Newbie requires help displaying data read from a f

Postby dneufarth » Wed May 13, 2020 6:04 am

Darren - and not a single example of your coding efforts to date. You were provided with avenues of attack, but showed nothing of your work.

I too cringe at some of the comments posted. Then I say to myself "so what." I just don't interact on those individual posts.

Some on this forum do indeed critique and/or proffer opinions. You need to toughen up and deal with those that provide you with workable suggestions as Mr Sample has pointed out.

There are quite a few posters here that have vast experience and skills you can not fathom yet. They, over many trying years, acquired them with help from others or put considerable time of their own scouring references/manuals and trial/error (creating amazing solutions to difficult business needs or tool creation) or both. Getting aid from them is a gift.

Your departure is, of course, your choice. I hope you get a solution.
dneufarth
 
Posts: 23
Joined: Thu Oct 15, 2009 2:50 am
Has thanked: 1 time
Been thanked: 2 times

Re: COBOL Newbie requires help displaying data read from a f

Postby Terry Heinze » Wed May 13, 2020 6:43 pm

Well stated, dneufarth.
.... Terry
Terry Heinze
 
Posts: 239
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 12 times
Been thanked: 11 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post