Reputation: 37
It's hard to explain but I have two columns one which is items ordered and one which is the price of an item. under the user needs to input the computers name and its price. The issue I'm having is I need to input on the same line and don't know how as I'm new to COBOL. example of what its supposed to look like is
ITEMS ORDERED___________ Price
Computer: Dell______________ 250.00
I try using
display "ITEMS ORDERED Price".
display "Computer: "with no advancing.
accept DESCRIPTION-OF-LAPTOP with no advancing.
accept LAPTOP-PRICE.
This just ends up putting it to the very top of the command prompt for some reason.
Upvotes: 2
Views: 1224
Reputation: 4407
With the standard ACCEPT
statement, it is possible to enter two (or more) fields on the same line; however, this is accepted as a single data item which must then be parsed to separate the fields. Tabs may be entered to line up the data so that it appears to be in two columns.
ITEMS ORDERED Price
Computer: Dell 250.00
Computer: HP 275.00
Computer:
In these cases, I used three tabs. However, only a single space is required to separate the price from the name. so the entries could look like these and still be accepted:
ITEMS ORDERED Price
Computer: Dell 2.00
Computer: Dell 20.00
Computer: Dell 200.00
Computer: Dell 2000.00
Computer: Dell 2.00
Computer: Dell 20.00
Computer: Dell 200.00
Computer:
Additional code is required to clean, parse, and validate before saving the data. (I used about 60 additional lines of code for that purpose.)
With SCREEN SECTION
, the exact placement and definition of each field is defined, therefore columns are aligned, parsing is not required, and validation is simplified.
SCREEN SECTION
was added to the 2002 standard as a Processor-dependent item and is not necessarily available on every, otherwise conforming, compiler. However, the feature has been available, in some form, in compilers since the 1980s.
Upvotes: 3