@x
@p program TFtoPL(@!tfm_file,@!pl_file,@!output);
@y
@p program TFtoPL(@!tfm_file,@!pl_file,@!output,@!input,@!term_out);
@z
@x
procedure initialize; {this procedure gets things started properly}
begin print_ln(banner);@/
@y
@<Procedures for initialization@>@/
procedure initialize; {this procedure gets things started properly}
begin
@<Preset initial values@>@/
print_ln(banner);@/
@z
@x
@!tfm_file:packed file of 0..255;
@y
@!tfm_file:packed file of block;
@!tfm_count:0..VAX_block_length; {where the next byte comes from}
@z
@x
@<Read the whole input file@>=
read(tfm_file,tfm[0]);
@y
@d read_tfm_file(#)==begin
if tfm_count=VAX_block_length then begin
get(tfm_file,@=error:=continue@>);
tfm_count:=0;
end;
#:=tfm_file^[tfm_count];
incr(tfm_count);
end
@<Read the whole input file@>=
read_tfm_file(tfm[0]);
@z
@x
if eof(tfm_file) then abort('The input file is only one byte long!');
@.The input...one byte long@>
read(tfm_file,tfm[1]); lf:=tfm[0]*@'400+tfm[1];
@y
read_tfm_file(tfm[1]); lf:=tfm[0]*@'400+tfm[1];
@z
@x
This section should be replaced, if necessary, by changes to the program
that are necessary to make \.{TFtoPL} work at a particular installation.
It is usually best to design your change file so that all changes to
previous sections preserve the section numbering; then everybody's version
will be consistent with the printed program. More extensive changes,
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
@y
Here are the remaining changes to the program
that are necessary to make \.{TFtoPL} work on Vax/VMS.
@ Here's the extra stuff we need for buffering the |tfm_file|.
@<Const...@>==
@!VAX_block_length=512;
@ @<Types...@>==
@!block=packed array [0..VAX_block_length-1] of 0..255;
@ @<Set init...@>=
tfm_count:=0;
@ On Vax/VMS we need the following special definitions, types, variables
and procedures to be able to get the file name from the command line,
or to prompt for them.
@ @<Glob...@>==
@!term_out: text; {for progress report to user's terminal}
@!command_line:packed array[1..300] of char;
@!cmd_len:sixteen_bits;
@!cmd_i:integer;
@!file_name,@!default_file_name:varying [300] of char;
@!ask,@!got_file_name: boolean;
@ @<Preset init...@>=
open(term_out,'SYS$OUTPUT',@=carriage_control:=none@>); rewrite(term_out);
cmd_i:=0;
VAX_lib_get_foreign(command_line,,cmd_len,cmd_i);
cmd_i:=1; while (cmd_i<=cmd_len) and (command_line[cmd_i]=' ') do incr(cmd_i);
got_file_name:=cmd_i<=cmd_len;
if got_file_name then
default_file_name:=substr(command_line,cmd_i,cmd_len-cmd_i+1);
if got_file_name then begin
file_name:=default_file_name+'.TFM';
open(tfm_file,file_name,@=readonly,error:=continue@>);
ask:=status(tfm_file)<>0;
if ask then write_ln('Coudln''t open ',file_name);
end
else ask:=true;
while ask do begin
got_file_name:=false;
write('TFM file: ');
if eof then goto final_end;
read_ln(file_name);
open(tfm_file,file_name,@=readonly,error:=continue@>);
ask:=status(tfm_file)<>0;
if ask then write_ln('Couldn''t open ',file_name);
end;
if got_file_name then begin
cmd_i:=1;
for cmd_len:=1 to default_file_name.VAX_length do
if (default_file_name[cmd_len]=']')
or (default_file_name[cmd_len]=':')
then cmd_i:=cmd_len+1;
if cmd_i<=default_file_name.VAX_length then
default_file_name:=substr(default_file_name,cmd_i,
default_file_name.VAX_length-cmd_i+1);
file_name:=default_file_name+'.PL';
open(pl_file,file_name,@=new,32767,disposition:=delete@>,
@=error:=continue@>);
ask:=status(pl_file)>0;
if ask then write_ln('Couldn''t open ',file_name);
end
else ask:=true;
while ask do begin
write('PL file: ');
if eof then goto final_end;
read_ln(file_name);
open(pl_file,file_name,@=new,32767,disposition:=delete@>,
@=error:=continue@>);
ask:=status(pl_file)>0;
if ask then write_ln('Couldn''t open ',file_name);
end;
@ Here is the library procedure that gets the user's command line.
@<Procedures for ...@>=
[VAX_external] function VAX_lib_get_foreign(
VAX_stdescr cmdlin:[VAX_volatile] packed array [$l1..$u1:integer] of char
:= VAX_immed 0;
VAX_stdescr prompt:[VAX_volatile] packed array [$l2..$u2:integer] of char
:= VAX_immed 0;
var len : [VAX_volatile] sixteen_bits := VAX_immed 0;
var flag : [VAX_volatile] integer := VAX_immed 0)
:integer; extern;