Version I.5, September 1978
This program alters the SYSTEM.PASCAL on the default P(refix disk. It prompts for ‘local GOTOXY’, a procedure which must be created and bound into the system (only once) in order to make the system communicate correctly with the screen.
An example of a GOTOXY procedure for a relatively stupid terminal follows. More intelligent terminals will require less effort to have the proper cursor addressing happen. It is suggested that you might want to fill an array or string with the appropriate characters to cause your terminal to do its absolute addressing, and then UNITWRITE the stream all at once. This will improve the performance of the screen editor noticeably. An example of this for the Datamedia 1520 follows the example for the DECscope VT-50.
If the GOTOXY cursor addressing scheme for the terminal is not there, create one. The procedure may not be named GOTOXY because this identifier is predeclared at the “$U-” level of compilation.
Possible error: Fix: Nil memory reference at compile time Remove the program heading and try again Value range error when executing BINDER (*$U-*) should be the first thing in the GOTOXY file
Assumptions:
Example:
The first example, for a DECscope VT-50, a terminal with very primitive cursor addressing, writes each character to the screen individually.
(*$U-,S+*)(* The pseudo comments inform the compiler of the correct state to be in for compiling this little routine. *) PROGRAM DUMMY;
PROCEDURE MYGOTOXY(X, Y: INTEGER); (* the procedure must NOT be called GOTOXY *) BEGIN (* Check the input data to see that it is within the screen dimensions, on some smarter terminals, if a cursor position command is sent for a position that does not exist, the results are unpredictable. *) IF X < 0 THEN X := 0 ELSE IF X > 79 THEN X := 79; IF Y < 0 THEN Y := 0 ELSE IF Y > 11 THEN Y := 11; (* For a DECscope VT-5O, GOTOXY needs to be implemented by: send the cursor home, 0,0 *) WRITE(CHR(27), 'H'); (* While TAB is meaningful, use it to move the cursor. *) WHILE X > 8 DO BEGIN WRITE(CHR(9)); X := X - 8; END; (* Finish off what portion of the x coordinate could not be absorbed with TAB characters. *) WHILE X > 0 DO BEGIN WRITE(CHR(27), 'C'); X := X - 1 END; (* send line-feeds to access the y coordinate *) WHILE Y > 0 DO BEGIN WRITE(CHR(10)); Y := Y - 1 END BEGIN (* This dummy body of the operating system is needed to keep the Pascal compiler happy about having complete programs to compile. The method used for 'binding' the GOTOXY procedure is somewhat unclean, and only the code for the above procedure is used by the binder to add to the SYSTEM.PASCAL file. *) END.
The next example, for a Datamedia 1520, shows how to collect all of the characters into a single array of characters and write it all to the terminal in a single system call.
PROGRAM DUMMY; PROCEDURE ITSGOTOXY(X, Y: INTEGER); VAR T: PACKED ARRAY[O..2] OF CHAR; BEGIN T[0] := CHR(30); (* RS is Datamedia's absolute cursor address flag *)
(* Set appropriate character for x coordinate. *) IF X < 0 THEN T[1] := CHR(32) ELSE IF X > 79 THEN T[1] := CHR(32 + 79) ELSE T[1] := CHR(X + 32); (* Set appropriate character for y coordinate. *) IF Y < 0 THEN T[2] := CHR(32) ELSE IF Y > 23 THEN T[2] := CHR(32 + 23) ELSE T[2] := CHR(32 + Y); (* Send the cursor where it belongs... WHAPPO! *) UNITWRITE(1, T, 3) END; BEGIN (* Same comment applies. *) END.