Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please, help me with working with files!! 1

Status
Not open for further replies.

VadimKhadkevich

Programmer
Nov 12, 2014
1
BY
I have FD

FD CR1
LABEL RECORD IS STANDARD
DATA RECORDS ARE FIRSTSTR, SECONDSTR, THIRDSTR.
and 3 structures

01 FIRSTSTR.
05 FIRSTFIVE PIC X(05).
05 SECONDFIVE PIC X(05).

01 SECONDSTR.
05 FIRSTTWO PIC X(02).
05 SECONDONE PIC X(01).
05 THIRDFOUR PIC X(04).

01 THIRDSTR.
05 FIRSTTHREE PIC X(03).
05 SECONDTHREE PIC X(03).
05 THIRDTHREE PIC X(03).
Can I write all info in file like this:

WRITE FIRSTSTR, SECONDSTR, THIRDSTR.
And read from file in 3 structures like this:

READ CR1 INTO FIRSTSTR, SECONDSTR, THIRDSTR AT END
??????
 
What does the syntax diagram in the manual for your version of COBOL say? What did your instructor at COBOL school say? If self-taught what did the books that you learned from say? What happened when you tried? (The compiler will answer such questions much faster than you can type them!)


Nic
 
Generally speaking different records defined in the same FD all share the same storage (i.e. are different views of the same area of memory). So writing all three records at one time will generate three separate records on the file but all with the exact same data.

Regarding the READ operation, you can only read one record at a time.

Since reads and writes process one item at a time, both the WRITE and READ statements you show, are syntactically incorrect.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top