% TOPS-20 change file for GFtoPK by Tomas Rokicki. Send bug reports to % ROKICKI@SU-SCORE. @x [1] \pageno=\contentspagenumber \advance\pageno by 1 @y \pageno=\contentspagenumber \advance\pageno by 1 \let\maybe=\iffalse \def\ttw{{\mc TOPS-20}} \def\title{GFtoPK changes for \ttw} @z @x [4] @d banner=='This is GFtoPK, Version 1.4' {printed when the program starts} @y @d banner=='This is GFtoPK, TOPS-20 Version 1.4' {printed on startup} @z @x [5] @d d_print_ln(#)== @y @d d_print_ln(#)== @z @x [6] @d print(#)==write(#) @d print_ln(#)==write_ln(#) @y @d print(#)==write(tty,#) @d print_ln(#)==write_ln(tty,#) @z @x [7] @p program GFtoPK(@!gf_file,@!pk_file,@!output); @y @p program GFtoPK; @z @x [7] @= @!line_length=79; {bracketed lines of output will be at most this long} @!terminal_line_length=150; {maximum number of characters input in a single line of input from the terminal} @!max_row=16000; {largest index in the main |row| array} @y @= @!line_length=79; {bracketed lines of output will be at most this long} @!terminal_line_length=150; {maximum number of characters input in a single line of input from the terminal} @!max_row=16000; {largest index in the main |row| array} @!name_length=80; {the maximum length of a name} @!max_rescan=200; {the maximum length of a command line} @z @x [50] begin reset(gf_file); @y begin reset(gf_file,gf_name,'/O/B:8'); @z @x [51] begin rewrite(pk_file); @y begin if startup then @ ; rewrite(pk_file,pk_name,'/O/B:8'); @z @x [51] @!pk_loc:integer; {where we are about to write, in |pk_file|} @!gf_loc:integer; {where are we in the |gf_file|} @y @!pk_loc:integer; {where we are about to write, in |pk_file|} @!gf_loc:integer; {where are we in the |gf_file|} @!pk_name, gf_name: packed array[1..name_length] of char; @z @x [95] initialize ; convert_gf_file ; @y initialize ; startup := true ; @ ; if not startup then begin print('GF file name: ') ; read_ln(tty, gf_name) ; print('PK file name: ') ; read_ln(tty, pk_name) ; end ; convert_gf_file ; @z @x [99] @* System-dependent changes. This section should be replaced, if necessary, by changes to the program that are necessary to make \.{GFtoPK} 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. @^system dependencies@> @y @* System-dependent changes. This section should be replaced, if necessary, by changes to the program that are necessary to make \.{GFtoPK} 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. @^system dependencies@> We call a system procedure to put the command line into the input buffer. We then read it in, skipping over the program name to the first blank. @d RSCAN=@'500 {ReSCAN buffer JSYS} @= jsys(RSCAN,1,i;0;j); {get the command line} if (i<>2) or (j<=0) then startup := false else begin if eoln(tty) then read_ln(tty); {for some TOPS-20's} read(tty,rescan_buffer:rescan_len); {read in rescan buffer} if rescan_len>max_rescan then abort('command line too long!'); read_ln(tty); if rescan_len=j-2 then startup := false else begin i:=1; while rescan_buffer[i]>' 'do incr(i); {skip invocation} while(i<=rescan_len) and (rescan_buffer[i]=' ')do incr(i); {skip spaces} if i>rescan_len then startup := false else begin for j := 1 to name_length do begin gf_name[j] := ' ' ; pk_name[j] := ' ' ; end ; j := 1 ; last_ext := -1 ; while ( i <= rescan_len ) and ( rescan_buffer[i] <> ' ' ) do begin gf_name[j] := rescan_buffer[i] ; pk_name[j] := rescan_buffer[i] ; if (rescan_buffer[i] = '.') and (last_ext = -1) then last_ext := j ; if rescan_buffer[i] in [':',']','>'] then last_ext := -1 ; incr(j) ; incr(i) ; end ; if last_ext = -1 then begin last_ext := j ; gf_name[j] := '.' ; gf_name[j+1] := 'g' ; gf_name[j+2] := 'f' ; end ; pk_name[last_ext] := '.' ; for i := last_ext+1 to name_length do pk_name[i] := ' ' ; end ; end ; end @ We also wait until we are done with the \.{GF} file to make the packed file name, so we can put the size information in it. @= begin if h_mag > 999 then begin incr(last_ext) ; pk_name[last_ext] := chr(ord('0')+h_mag div 1000) ; end ; pk_name[last_ext+1] := chr(ord('0')+h_mag div 100 mod 10) ; pk_name[last_ext+2] := chr(ord('0')+h_mag div 10 mod 10) ; pk_name[last_ext+3] := chr(ord('0')+h_mag mod 10) ; pk_name[last_ext+4] := 'p' ; pk_name[last_ext+5] := 'k' ; end @ @= @!rescan_buffer:packed array[1..max_rescan] of char; @!rescan_len:integer; @!j : integer ; {general purpose index} @!startup : boolean ; {did we have a file name?} @!last_ext : integer ; {where was the dot?} @z