home *** CD-ROM | disk | FTP | other *** search
- { File: CHECKESC.INC }
-
-
- { Definitions for checking out escape sequences, and responding }
- Const
- NumberOfEscapeSequences = 10;
-
- Var
- EscapeSeq : ARRAY [1..NumberOfEscapeSequences] OF STRING[6];
-
-
- Procedure InitEscSeq;
- { Initialize values of escape sequences to check for in CheckEscSeq }
- Begin
- EscapeSeq[1] := 'c'; { Terminal Reset (This would reset RB) }
- EscapeSeq[1][0] := Chr(1); { Don't count on auto length init. }
- EscapeSeq[2] := '='; { Keypad Application Mode }
- EscapeSeq[2][0] := Chr(1);
- EscapeSeq[3] := '>'; { Keypad Numeric Mode }
- EscapeSeq[3][0] := Chr(1);
- EscapeSeq[4] := 'Z'; { Terminal ID Request }
- EscapeSeq[4][0] := Chr(1);
- EscapeSeq[5] := '[Z'; { "" }
- EscapeSeq[5][0] := Chr(2);
- EscapeSeq[6] := '[c'; { "" }
- EscapeSeq[6][0] := Chr(2);
- EscapeSeq[7] := '[0c'; { "" }
- EscapeSeq[7][0] := Chr(3);
- EscapeSeq[8] := '[5i'; { Print Controller on }
- EscapeSeq[8][0] := Chr(3);
- EscapeSeq[9] := '[4i'; { Print Controller off }
- EscapeSeq[9][0] := Chr(3);
- EscapeSeq[10] := '[?15n'; { Check Printer Status }
- EscapeSeq[10][0] := Chr(5);
- end;
-
- Procedure CheckEscSeq;
- { Evaluate any escape sequences that come in, and respond
- appropriately }
-
-
- Var
- Counter : Byte;
- PartialMatch, FullMatch : Boolean;
- StoreString : String[6];
-
- Begin
- StoreString[0] := Chr(0); { Don't count on auto length init. }
-
- Repeat { Keep getting and checking characters until there's
- no match with any search strings }
- GetCommChar; { Get the next character in the esc seq }
- StoreString := StoreString + CommIn.Char;
- Counter := 0;
- PartialMatch := False;
- FullMatch := False;
-
- { Check if StoreString is in list }
- While (Counter < NumberOfEscapeSequences) And
- (Not FullMatch) Do
- Begin
- Counter := Counter + 1;
- If Pos(StoreString,EscapeSeq[Counter]) = 1 Then
- Begin
- PartialMatch := True;
- If StoreString = EscapeSeq[Counter] Then
- FullMatch := True;
- End { There was at least a partial match }
- End; { While }
- Until (Not PartialMatch) OR (FullMatch);
-
-
- If Not PartialMatch Then
- Begin
- If DisplayOn And Not Printeron
- Then Write(Esc,StoreString)
- Else If PrinterOn
- Then Write(Lst,Esc,StoreString)
- Else Begin
- Write(Esc,StoreString);
- Write(Lst,Esc,StoreString);
- End; { both display and print }
- If LoggingOn Then Write(FileVar,Esc,StoreString);
- End;
-
- If FullMatch = True Then
- Case Counter of
- { Put in the choices and procedures to run here }
- 1: ; { Ignore terminal reset request }
- 2: ApplicationKeypadMode; { Chg keys to Appl }
- 3: NumericKeypadMode; { Chg keys to Num }
- 4..7: WriteCommString(TermID); { term ID request }
- 8: Begin { Print controller on request }
- PrinterOn := True;
- DisplayOn := False;
- End;
- 9: Begin { Print controller off request }
- PrinterOn := False;
- DisplayOn := True;
- End;
- 10: { Printer status request }
- If CheckPrinter
- Then WriteCommString(PrinterReady)
- Else WriteCommString(PrinterNotReady);
- End; { Case statement }
-
- End; { Procedure CheckEscSeq }
-