%include "level1:graphinc.imp"
%include "inc:util.imp"
%begin; !Display text on frame store screen
        !With V200 escape sequences as follows:
        !Graphics/Non-Graphics Mode
        !Foreground/Background Mode
        !Cursor-addressing (ignored)

%constinteger cr=13,ff=12

%constinteger height=11

%integer paper=black,ink=cyan,sym
%constinteger esc=27
%integer graphmode=0
%string(31)file

%onevent 3,9 %start
  printstring(event_message); newline; %stop
%finish

prompt("File:")
!readsymbol(sym) %until nl#sym#' '; file = ""
!%while sym#',' %and sym#' ' %and sym#nl %cycle
!  file = file.tostring(sym) %unless length(file)=31
!  readsymbol(sym)
!%repeat
!sym = testsymbol
openinput(1,cliparam)
!read font
font(0)

 colour(paper); fill(0,0,1023,1023); colour(ink)
prompt(":")
selectinput(1)
textat (0,1023)
%cycle
  readsymbol(sym)
  %if sym=nl %or sym=ff %start
    %if sym=ff %or testsymbol>=0 %start
      sym = testsymbol %until sym>=0
    %finish
    sym = nextsymbol; !Provoke EOF
    textat (0, textypos-height{-1})
    colour(paper)
    hline(0,1023,textypos+sym-20) %for sym=0,1,height
    colour(ink)
    !offset(0,-textypos)
  %finishelseif sym=cr %start
    textat (0,textypos)
  %finishelseif sym=esc %start
    readsymbol(sym)
    %if sym='F' %start;           !Graph mode
      graphmode = 1
    %finishelseif sym='G' %start; !Non-Graph mode
      graphmode = 0
    %finishelseif sym='3' %start; !Foreground
      ink = cyan; colour(ink)
    %finishelseif sym='4' %start; !Background
      ink = magenta; colour(ink)
    %finishelseif sym='Y' %start;  !Position cursor
      readsymbol(sym); readsymbol(sym)
    %finish
  %finishelsestart
    %if graphmode#0 %start
      sym = ' ' %if sym=95; sym = sym-96 %if sym>=96
    %finish
    showsymbol(sym)
  %finish
%repeat

%endofprogram
