[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
Tue Sep 19 20:46:24 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!
Fortran:
$ type relwrt.for
program relwrt
integer*4 i, buflen
character*80 buf
open(unit=1,file='rel.dat',status='new',form='formatted',
+ organization='relative',recl=512,recordtype='variable',
+ access='direct')
do 100 i = 1, 100
write(buf,'(14HThis is line #,i4.4,1H!)') i
buflen = index(buf,'!')
write(unit=1,rec=i) buf(1:buflen)
100 continue
close(unit=1)
end
$ for relwrt
$ link relwrt
$ run relwrt
$ type relrdseq.for
program relrdseq
integer*4 i, buflen
character*80 buf
open(unit=1,file='rel.dat',status='old',form='formatted',
+ organization='relative',recl=512,recordtype='variable',
+ access='sequential')
100 read(unit=1,fmt='(q,a)',end=200) buflen,buf
write(*,*) '|'//buf(1:buflen)//'|'
goto 100
200 close(unit=1)
end
$ for relrdseq
$ link relrdseq
$ run relrdseq
|This is line #0001!|
|This is line #0002!|
...
|This is line #0100!|
$ type relrddir.for
program relrddir
integer*4 i, buflen
character*80 buf
open(unit=1,file='rel.dat',status='old',form='formatted',
+ organization='relative',recl=512,recordtype='variable',
+ access='direct')
do 200 i = 1, 100
read(unit=1,fmt='(q,a)',rec=i) buflen,buf
write(*,*) '|'//buf(1:buflen)//'|'
200 continue
close(unit=1)
end
$ for relrddir
$ link relrddir
$ run relrddir
|This is line #0001!|
|This is line #0002!|
...
|This is line #0100!|
Arne
More information about the Info-vax
mailing list