%begin
! GIL view program    KJC
! -----------------------

%include "edwin:consts.inc"
%include "edwin:specs.inc"
%external %routine %spec RECTANGLE      %alias "EDWIN_RECTANGLE"  (%integer XL, YL, XU, YU)

%integer c, i,j, k, l
%string(31) input file

%on %event 9 %start
    terminate edwin
    print string("EOF detected - stop"); newline
   %stop
%finish

%routine read line (%string (*) %name line)

! Reads in a line of characters, and removes all blanks

   %integer char

   line = ""
   skip symbol %while next symbol = nl %or next symbol = ' '
   %while next symbol # nl %cycle
      read symbol (char)
      %continue %if char = ' '
      line = line.tostring (char)
   %repeat
   skip symbol

%end {* Read Line *}

prompt("Input file?:")
read line(input file)
open input(1, input file)
!open input(1, "input.gil")
select input(1)

initialisefor(defaultdevice)
set colour(blue);   ! default
set colour mode(2)
new frame

%cycle
   skip symbol %while next symbol=' ' %or next symbol=nl
   read symbol(c)
   %if c='A' %start
      ! Init
      read(i); read(j); read(k); read(l)
      Window(i,k,j,l)
   %finish
   %if c='B' %start
      ! Box
      read(i); read(j); read(k); read(l)
      rectangle(i,j,k,l)
   %finish
   %if c='C' %start
      ! Set Colour
      read(i)
      set colour(i)
   %finish
   %if c='L' %start
      ! Line
      read(i); read(j); read(k); read(l)
      moveabs(i,j)
      lineabs(k,l)
   %finish
   %if c='S' %start
      ! Set Style
      read(i)
      set shade mode(i)
!      %if i=0 %then set shade mode(0) %else set shade mode(1)
!      %if i=3 %then set shade mode(0);  ! quick hack for pp and np
   %finish
   %if c='!' %start
      ! Comment !
      skip symbol %while next symbol#nl
   %finish
   %if c='E' %then %exit
   skip symbol;   ! {nl}
%repeat

terminate edwin

%endofprogram
