DEFINITION MODULE TermBase; (* (C) Copyright 1987 Fitted Software Tools. All rights reserved. *) (* The module Terminal does all of its work thru the procedures KeyPressed, Read and Write in this module. The behaviour of these procedures can be modified by assigning new procedures to do the work using AssignRead and AssignWrite. *) TYPE StatusProcedure = PROCEDURE() :BOOLEAN; ReadProcedure = PROCEDURE( VAR CHAR ); WriteProcedure = PROCEDURE( CHAR ); PROCEDURE AssignRead( rp :ReadProcedure; sp :StatusProcedure; VAR done :BOOLEAN ); (* save the current Read and KeyPressed procedures in a stack and install the new procedures to be used in their place *) PROCEDURE AssignWrite( wp :WriteProcedure; VAR done :BOOLEAN ); (* save the current Write procedure in a stack and install the new procedure to be used in its place *) PROCEDURE UnAssignRead( VAR done :BOOLEAN ); (* pop the Read and KeyPressed procedures saved by InstallRead off the stack and make them active again. *) PROCEDURE UnAssignWrite( VAR done :BOOLEAN ); (* pop the Write procedure saved by InstallWrite off the stack and make it active again. *) PROCEDURE KeyPressed() :BOOLEAN; (* invokes the currently installed KeyPressed procedure. During TermBase initialization, TermIO.KeyPressed is installed. *) PROCEDURE Read( VAR ch :CHAR ); (* invokes the currently installed Read procedure. During TermBase initialization, TermIO.Read is installed. *) PROCEDURE Write( ch :CHAR ); (* invokes the currently installed Write procedure. During TermBase initialization, TermIO.Write is installed. *) END TermBase.