[Info-vax] Example of random access by record number on an RMS fixed record size, relative organization file?
Arne Vajhøj
arne at vajhoej.dk
Thu Sep 21 20:31:43 EDT 2023
On 9/19/2023 8:44 PM, Arne Vajhøj wrote:
> On 9/16/2023 4:16 PM, Arne Vajhøj wrote:
>> I don't think I have ever used ORG=REL.
>
> But then I could start now!
Cobol:
$ type relwrt.cob
identification division.
program-id.relwrt.
*
environment division.
input-output section.
file-control.
select optional f assign to "rel.dat" organization is relative access
mode is dynamic relative key is recno.
*
data division.
file section.
fd f.
01 myrec.
03 buf pic x(512).
working-storage section.
01 recno pic 9(9) comp.
01 i pic 9(9) comp.
01 i2 pic 9(9) display.
*
procedure division.
main-paragraph.
open i-o f
perform varying i from 1 by 1 until i > 100
move i to recno
move i to i2
string "This is line #" delimited by size i2 delimited by size
"!" delimited by size into buf
write myrec
invalid key continue
not invalid key continue
end-write
end-perform
close f
stop run.
$ cob relwrt
$ link relwrt
$ run relwrt
$ type relrdseq.cob
identification division.
program-id.relrdseq.
*
environment division.
input-output section.
file-control.
select f assign to "rel.dat" organization is relative access mode is
dynamic relative key is recno.
*
data division.
file section.
fd f.
01 myrec.
03 buf pic x(512).
working-storage section.
01 recno pic 9(9) comp.
01 eof pic x(1) value 'N'.
*
procedure division.
main-paragraph.
open i-o f
perform until eof = 'Y'
read f next
at end move 'Y' to eof
not at end display "|" buf "|"
end-read
end-perform
close f
stop run.
$ cob relrdseq
$ link relrdseq
$ run relrdseq
|This is line #000000001!|
|This is line #000000002!|
...
|This is line #000000100!|
$ type relrddir.cob
identification division.
program-id.relrddir.
*
environment division.
input-output section.
file-control.
select f assign to "rel.dat" organization is relative access mode is
dynamic relative key is recno.
*
data division.
file section.
fd f.
01 myrec.
03 buf pic x(512).
working-storage section.
01 recno pic 9(9) comp.
01 i pic 9(9) comp.
*
procedure division.
main-paragraph.
open i-o f
perform varying i from 1 by 1 until i > 100
move i to recno
read f
invalid key continue
not invalid key display "|" buf "|"
end-read
end-perform
close f
stop run.
$ cob relrddir
$ link relrddir
$ run relrddir
|This is line #000000001!|
|This is line #000000002!|
...
|This is line #000000100!|
Arne
More information about the Info-vax
mailing list