{ Set "constant variables" }

PAGELEN := SCREENBOTTOM-SCREENTOP+1;    { max. no. of lines on screen page }
LINELEN := SCREENRIGHT-SCREENLEFT+1;    { max. no. of chars on screen line }

{ Initialize code sets }

digits := ['0'..'9'];
letters := ['A'..'Z'] + ['a'..'z'];
alphanums := digits + letters;
separators := [#0..#$7E] - alphanums;

{ Init expand function table - simple version }

for i:=0 to 31 do
    exp_length[i] := 0;
for i:=32 to 127 do
    exp_length[i] := 1;

{ Init text array and screen }

text_end := TEXTSTART-1;
ClrScr;
prompt_for_filename(textname,'_File: ');
if empty_string(textname) then Halt;

open_readfile(textname,textfile);
if not file_flag then Halt;
read_text_from_file(textfile);
text_end := text_end+1; text[text_end]:=CR;

n_lines:=0; for i:=TEXTSTART to text_end do if eol(i) then n_lines:=n_lines+1;

insert_flag:=true; write(cursor2);
block_flag:=false; block_begin:=TEXTSTART; block_end:=block_begin-1;
to_top_of_file; old_index:=TEXTSTART;
