|
|
DataMuseum.dkPresents historical artifacts from the history of: Bogika Butler |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Bogika Butler Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 5504 (0x1580)
Types: TextFile
Names: »TFINPUT.PAS«
└─⟦59c2ecd8d⟧ Bits:30009789/_.ft.Ibm2.50006600.imd Mogens Pelles Zilog 80,000 / EOS projekt
└─⟦this⟧ »TFINPUT.PAS«
(********************************************************************)
(* *)
(* INPUT MODULE starts *)
var
in_file : text;
in_file_name : name;
divide_file : file of integer;
(* for new divide-points *)
new_dividepoints : boolean;
(* tells if there is any new divide-points *)
attr : attribute_set;
(* current attributes *)
position : array(.index.) of 1..input_line_length;
(* converts indices for new divide-points to input-line indices.
Valid for the last line read *)
line_nr : integer;
(* line number of last line read *)
procedure init_input(filename : name; var ok : boolean);
begin
in_file_name := filename;
assign(in_file, in_file_name);
(*$I-*) reset(in_file); (*$I+*)
ok := ioresult = 0;
if ok then begin
assign(divide_file, divide_file_name);
rewrite(divide_file);
end;
new_dividepoints := false;
attr := (..);
line_nr := 0;
end;
function eof_input : boolean;
begin
eof_input := eof(in_file)
end;
procedure get_line_input(var line : f_string);
var buffer : string(.input_line_length.);
i : integer;
line_len : index0;
begin
readln(in_file, buffer);
line_nr := line_nr+1; line_len := 0; i := 1;
while i <= length(buffer) do begin
if buffer(.i.) = '^' then begin
i := i+1;
if i > length(buffer) then insert(cr, buffer, i);
case buffer(.i.) of
'U' : attr := attr+(.underscore.);
'u' : attr := attr-(.underscore.);
'F' : attr := attr+(.bold.);
'f' : attr := attr-(.bold.);
'K' : attr := attr+(.italic.);
'k' : attr := attr-(.italic.);
'P' : attr := attr+(.proportional.);
'p' : attr := attr-(.proportional.);
'B' : attr := attr+(.nlq.);
'b' : attr := attr-(.nlq.);
'E' : attr := attr+(.unidirectional.);
'e' : attr := attr-(.unidirectional.);
's' : attr := attr-(.superscript.)+(.subscript.);
'S' : attr := attr-(.subscript.)+(.superscript.);
'N', 'n' : attr := attr-(.superscript, subscript.);
'-' : attr := attr+(.dividepoint.);
'^' : begin
line_len := line_len+1;
position(.line_len.) := i-1;
line(.line_len.).ch := '^';
line(.line_len.).attr := attr;
attr := attr-(.dividepoint.)
end;
' ', cr : begin
line_len := line_len+1;
position(.line_len.) := i-1;
line(.line_len.).ch := forced_space;
line(.line_len.).attr := attr;
attr := attr-(.dividepoint.)
end;
else
(* nothing *)
end;
i := i+1;
end else begin (* not a ^ *)
line_len := line_len+1;
position(.line_len.) := i;
line(.line_len.).ch := buffer(.i.);
line(.line_len.).attr := attr;
attr := attr-(.dividepoint.);
i := i+1;
end;
end; (* while *)
attr := attr-(.dividepoint.);
while (line(.line_len.).ch = ' ') and (line_len > 1) do
line_len := line_len-1;
if line(.line_len.).ch = ' ' then line_len := 0;
f_fill(cr, (..), line, line_len+1, f_len)
end; (* get_line_0 *)
procedure insert_dividepoint_input(pos : index);
(* specifies that a new divide-point shall be inserted before
the character at the stated position in the line last read.
It is assumed that divide-points are inserted from left to right *)
var p : integer;
begin
p := position(.pos.);
write(divide_file, line_nr, p);
new_dividepoints := true
end;
procedure terminate_input;
var revised_file : text;
updates, update_line, update_pos : integer;
buffer : string(.input_line_length.);
procedure write_line;
begin
if length(buffer) > max_line_len then
writeln('Advarsel: Linie ', line_nr,
' er blevet for lang ved indsættelse af delepunkter');
writeln(revised_file, buffer);
end;
begin
close(in_file); close(divide_file);
if new_dividepoints then begin
assign(revised_file, revised_file_name);
rewrite(revised_file);
reset(in_file); reset(divide_file);
readln(in_file, buffer); line_nr := 1; updates := 0;
while not eof(divide_file) do begin
read(divide_file, update_line, update_pos);
while line_nr < update_line do begin
write_line;
readln(in_file, buffer);
line_nr := line_nr+1; updates := 0;
end;
insert('^-', buffer, update_pos+2*updates);
updates := updates+1;
end;
while not eof(in_file) do begin
write_line;
readln(in_file, buffer);
line_nr := line_nr+1;
end;
write_line;
close(revised_file); close(in_file); close(divide_file);
erase(in_file); rename(revised_file, in_file_name);
erase(divide_file)
end; (* if new_dividepoints *)
end; (* terminate_0 *)
(* INPUT MODULE ends *)
(* *)
(********************************************************************)
«eof»