include "$EDWIN:.INC"
begin

! EDWIN test program 1
! This program tests the ability to draw lines and to read the cursor.
! The program reads four cursor locations, and then joins these by
! a mesh of lines.
! This is repeated until 'S' is the key hit in response to the cursor.

const integer NUM = 10
integer I,CVAL,TYPE
integer array X,Y (1:4)

PROMPT ("Device Type:")
READ (TYPE)
INITIALISE FOR (TYPE)

NEW FRAME;    ! This clears the screen

cycle
   for I=1,1,4 cycle
      ! This cycle reads the 4 points defining the two primary lines.
      CURSOR (CVAL, X(I) , Y(I))
      exit if CVAL = 'S' or CVAL = 's'   ;   ! This stops the program.
      if I&1=1 then MOVE ABS(X(I),Y(I)) else LINE ABS (X(I),Y(I))
   repeat
 
   exit if CVAL = 'S' or CVAL = 's'

   ! Now the points on these lines are joined up.

   for I=0,1,NUM cycle
      MOVEABS (X(1) + I*(X(2)-X(1))//NUM, Y(1) + I*(Y(2)-Y(1))//NUM)
      LINEABS (X(3) + I*(X(4)-X(3))//NUM, Y(3) + I*(Y(4)-Y(3))//NUM)
   repeat
repeat

TERMINATE EDWIN

end of program