Technical information
Serial Solutions Pasterm
Figure 9-3. Procedure OutStr.__________________________
{Send a string to serial port}
{Must deal here with any errors}
PROCEDURE OutStr (s :String);
VAR
i: Integer;
BEGIN
{$I-}
FOR i := 1 TO Length( s ) DO
Write(Com_Out, s[i]);
{$I+}
IF
IoResult <> 0 { Write failure}
THEN
Screen(’Failed to output characters to port.’+Newl,Fromctrl);
END;
The output procedure in Pascal used is Write. As before
IOResult is used to trap errors that may have occurred.
Closing The File._______________
The procedure Close_Com, Figure 9-4, closes the file.
Figure 9-4. Procedure Close_Com.______________________________
{Close com files. Checks that they are open first}
PROCEDURE Close_Com;
BEGIN
{$I-} { Disable I/O checking}
IF
FileRec(Com_Inp).Mode = fmInput
THEN
Close(Com_Inp);
IF
FileRec(Com_Out).Mode = fmOutput
THEN
Close(Com_Out);
{$I+}
END;
The Pascal procedure Close does not access the device driver,
but merely informs DOS and Pascal that the program no longer
wishes to use the file. Close_Com is performed just before the
program ends, during a change of port on the ’C’ command in
Pasterm, or during Open_Com if the open fails.
Page 146 Chapter 9