[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:48:35 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!
Pascal:
$ type relwrt.pas
program relwrt(input,output);
type
string = varying [255] of char;
var
i : integer;
buf : string;
f : file of string;
begin
open(f, 'rel.dat', new,
organization := relative, record_length := 512, record_type :=
variable,
access_method := direct);
rewrite(f);
for i := 1 to 100 do begin
buf := 'This is line #' + dec(i, 4);
locate(f, i);
f^ := buf;
put(f);
end;
close(f);
end.
$ pas relwrt
$ link relwrt
$ run relwrt
$ type relrdseq.pas
program relrddir(input,output);
type
string = varying [255] of char;
var
i : integer;
buf : string;
f : file of string;
begin
open(f, 'rel.dat', old,
organization := relative, record_length := 512, record_type :=
variable,
access_method := sequential);
reset(f);
while not eof(f) do begin
buf := f^;
writeln('|' + buf + '|');
get(f);
end;
close(f);
end.
$ pas relrdseq
$ link relrdseq
$ run relrdseq
|This is line #0001|
|This is line #0002|
...
|This is line #0100|
$ type relrddir.pas
program relrddir(input,output);
type
string = varying [255] of char;
var
i : integer;
buf : string;
f : file of string;
begin
open(f, 'rel.dat', old,
organization := relative, record_length := 512, record_type :=
variable,
access_method := direct);
reset(f);
for i := 1 to 100 do begin
find(f, i);
buf := f^;
writeln('|' + buf + '|');
end;
close(f);
end.
$ pas 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