View previous topic :: View next topic
|
Author |
Message |
swathiravichandran
New User
Joined: 21 Jul 2008 Posts: 19 Location: Mumbai
|
|
|
|
In cobol,do we have any option of reading a file in input-output mode.If yes means,please help me out with syntax. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
OPEN I-O mode ? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
Back to top |
|
|
swathiravichandran
New User
Joined: 21 Jul 2008 Posts: 19 Location: Mumbai
|
|
|
|
Thanks for ur valuable reply..may i use Read I-O file name in my program |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
No, it's OPEN I-O in PROCEDURE-DIVISION.
Below code might help you to understand this, this code searches the file for a record with a certain address, and then changes that address (note : RECORD-FOUND & WS-END-OF-DATA-FILE must first be declared in Working-Storage section) :
Code: |
PROCEDURE DIVISION.
PARA-1.
OPEN I-O DATA-FILE-1.
READ DATA-FILE-1
AT END
MOVE "E" TO WS-END-OF-DATA-FILE
DISPLAY "DATA NOT FOUND"
END-READ
PERFORM UNTIL END-OF-DATA-FILE OR RECORD-FOUND
IF ADDRESS = "New Zealand"
THEN
MOVE "Australia" TO ADDRESS
REWRITE PERSON-REC
MOVE "Y" TO WS-RECORD-FOUND
ELSE
READ DATA-FILE-1
AT END
MOVE "E" TO WS-END-OF-DATA-FILE
DISPLAY "DATA NOT FOUND"
END-READ
END-IF
END-PERFORM
CLOSE DATA-FILE-1
STOP RUN. |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
read file
write record |
|
Back to top |
|
|
umasankarmf
New User
Joined: 08 Sep 2008 Posts: 43 Location: india
|
|
|
|
Hi,
Most probably I-O mode is used for rewrite the records. i.e. first read and then write.(for reading it acts as input mode and for writing it acts as output mode).
If any corrections welcome..... |
|
Back to top |
|
|
|