
Controlling E9Screen
EPC9 Installation
93
Sample program
The listing below is an excerpt from the program used to test the E9Screen
communication protocol. It demonstrates the functions needed to write an own program
to control the EPC9 through the E9Screen program. The code is written in Modula-2. The
code can be easily understood also by readers familiar with BASIC, PASCAL, C, C++, or
FORTRAN.
MODULE UserCommands;
CONST
CommandName = 'EPC9In.EPC';
MessageName = 'EPC9Out.EPC';
VAR
CommandFile : IOFiles.FileHandleType;
MessageFile : IOFiles.FileHandleType;
Signature : INTEGER;
LastSignature : INTEGER;
PROCEDURE WriteError( Text : ARRAY OF CHAR );
VAR
Work : ARRAY[0..79] OF CHAR;
BEGIN
IOFiles.Message( IOFiles.GetError(), Work );
TermIO.WriteString( Text );
TermIO.WriteString( ' failed: ' );
TermIO.WriteLine( Work );
Alert.Beep;
END WriteError;
PROCEDURE WriteToCommandFile( Text : ARRAY OF CHAR ): BOOLEAN;
VAR
Work : ARRAY[0..79] OF CHAR;
Count : INTEGER;
BEGIN
IF NOT CommandFile.IsOpen THEN RETURN FALSE; END;
IF Text[0] = 0C THEN RETURN TRUE; END;
Work[0] := 0C;
Decode.Integer( - ABS( Signature ), Work, 0 );
Count := Strings.Length( Work );
(* First, we write a negative signature to the first text line.
This prevents to the target E9Screen to read and interpret
the content of this file. We use the actual signature already
now, so that we can just change the sign from negative to
positive by overwriting one character!
*)
IF