{ Handles Hazeltine 1500 series with ~ as lead in character }

{$U-}	  { ALWAYS include this compiler directive. }
UNIT GOTOXY;
INTERFACE
  PROCEDURE AGOTOXY(X,Y: INTEGER);
  
IMPLEMENTATION
USES {$U SCREENOPS.CODE} SCREENOPS (SC_TX_PORT, SC_PORT);
  PROCEDURE AGOTOXY;
  
  CONST	 TELL_LENGTH_MINUS_1 = 3;
  
  { You may have to change these, depending on your terminal. }
  
  VAR	  TELL: PACKED ARRAY [0..TELL_LENGTH_MINUS_1]
		 OF 0..255;
  BEGIN
    IF X>79 THEN X:=79
       ELSE IF X<0 THEN X:=0;
    IF Y>23 THEN Y:=23
       ELSE IF Y<0 THEN Y:=0;
    {  This range-checking is necessary.  The actual
	screenwidth and height may be different for you. }
	
    WITH SC_PORT DO
      BEGIN
	CUR_X:=X-COL;
	CUR_Y:=Y-ROW;
      END;
      
    { These first elements of TELL must contain
       the characters which tell your terminal to
       position the cursor at (X,Y):
       fill in the blanks...	     }
    TELL[0] := ORD('~');    TELL[1] := 17;
    { The actual X and Y values are usually the 
       last things in the array;
       the order may be different on your terminal. }
    IF X < 31 THEN TELL[2]:=X+96 ELSE TELL[2] := X;
    TELL[3] := Y+32;
    
    UNITWRITE(1,TELL,4,0,12)
  END {AGOTOXY};
END {UNIT GOTOXY}.

                                                                                                                                                                                                                                                            