Loading

GET and PUT statements in Easytrieve

GET and PUT statements are used to Read and Write to/from a file.
See a sample Easytrieve program below.

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 LIST ON
 FILE INFILE FB(80 200)
   IN-REC 1 80 A
 FILE OUTFILE FB(80 200)
   OUT-REC 1 80 A
*
 WS-COUNT W 4 N VALUE 0
*
 JOB INPUT NULL
 GET INFILE
 DO WHILE NOT EOF INFILE
   MOVE IN-REC TO OUT-REC
   PUT OUTFILE
   WS-COUNT = WS-COUNT + 1
   GET INFILE
 END-DO
 DISPLAY WS-COUNT ' RECORDS WRITTEN'
 STOP 

Also learn about READ and WRITE statements.

There is another simple way to do this, using PUT FROM

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
...
 JOB INPUT NULL
 GET INFILE
 DO WHILE NOT EOF INFILE
   PUT OUTFILE FROM INFILE
   WS-COUNT = WS-COUNT + 1
   GET INFILE
 END-DO
 DISPLAY WS-COUNT ' RECORDS WRITTEN'
 STOP 

Related Posts




blog comments powered by Disqus

There's 9 Comments So Far

Share your thoughts, leave a comment!