Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!GWUSUN.GWU.EDU!mfeldman From: mfeldman@GWUSUN.GWU.EDU (Mike Feldman) Newsgroups: comp.lang.modula2 Subject: screen-clear and cursor-move operations Message-ID: <8905122116.AA06121@gwusun> Date: 12 May 89 21:15:59 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Modula2 List Organization: The Internet Lines: 74 Things like screen-clear, cursor-move, etc., are not standard M2 library functions. There are 2 choices: use a compiler-specific library or try to write a portable mini-screen package. We have done the latter at GWU - this works with any terminal that can emulate a vt100 (including a PC with ANSI.SYS installed in the CONFIG.SYS file). This compiles under half-a-dozen different VMS, Unix, DOS compilers I have known and loved. ......cut here.... DEFINITION MODULE vt100; (* EXPORT QUALIFIED ClearScreen, SetCursorAt; *) PROCEDURE ClearScreen; PROCEDURE SetCursorAt(Column, Row: CARDINAL); END vt100. IMPLEMENTATION MODULE vt100; FROM InOut IMPORT Write; VAR ASCIIOffset: CARDINAL; PROCEDURE ClearScreen; BEGIN Write(CHR(27)); Write('['); Write('2'); Write('J'); END ClearScreen; PROCEDURE SetCursorAt(column, row: CARDINAL); BEGIN Write(CHR(13)); (* the newline is just to flush the buffer *) (* this is often necessary because InOut uses *) (* buffered I/O at the OS level and you don't *) (* want the OS to flush on its own - you'll get *) (* spurious newlines in the screen transaction *) (* You can delete this if it works on your OS *) (* without it *) Write(CHR(27)); Write('['); Write(CHR((row DIV 10) + ASCIIOffset)); Write(CHR((row MOD 10) + ASCIIOffset)); Write(';'); Write(CHR((column DIV 10) + ASCIIOffset)); Write(CHR((column MOD 10) + ASCIIOffset)); Write('H'); END SetCursorAt; BEGIN ASCIIOffset := ORD("0"); END vt100. ......cut here.... Have fun with this - modify it as you see fit. --------------------------------------------------------------------------- Prof. Michael Feldman Department of Electrical Engineering and Computer Science The George Washington University Washington, DC 20052 +1-202-994-5253 mfeldman@gwusun.gwu.edu mfeldman@gwuvm.bitnet ---------------------------------------------------------------------------