MODULE KermitParms ; (* Deal with various Kermit Parameters: Set and Show *) (* 29-Nov-83 Allow eight bit file transfer [pgt001] *) EXPORTS PROCEDURE SetParameters ; PROCEDURE DoShow ; PRIVATE IMPORTS KermitGlobals FROM KermitGlobals ; IMPORTS RS232Baud FROM RS232Baud ; IMPORTS CmdParse FROM CmdParse ; IMPORTS PopCmdParse FROM PopCmdParse ; IMPORTS PopUp FROM PopUp ; IMPORTS Perq_String FROM Perq_String ; PROCEDURE SetParameters ; (* Set Kermit flags and other communications features -pt*) VAR id, parm: String ; (* SET identifier and (possible) parameter *) switch, parmsw: Boolean ; (* Switch flags for feature and parameter *) index: Integer ; (* Command index *) PROCEDURE DoBaudRate( NewRate: String ) ; (* Try to set a new baud rate for the RS232 port *) CONST InputEnable = True ; (* Enable RS232 input *) HANDLER BadBaudRate ; BEGIN (*-BadBaudRate-*) Writeln('?Bad baud rate given: ', NewRate) ; EXIT( DoBaudRate ) END ; (*-BadBaudRate-*) BEGIN (*-DoBaudRate-*) IF (NewRate = '') THEN Writeln('%No value for SET SPEED') ELSE BEGIN (* set the rate *) SetBaud( NewRate, InputEnabled) ; (* Here if that was successful, save the new rate *) BaudRate := NewRate END END ; (*-DoBaudRate-*) FUNCTION MkOctal( src: String ): Integer ; (* convert the octal number in the source string into a number *) VAR i, sum: Integer ; (* index and summation value *) ok: Boolean ; (* loop control *) BEGIN (*-MkOctal-*) ok := True ; i := 1 ; sum := 0 ; WHILE ok DO IF NOT (src[i] IN ['0'..'7']) THEN ok := False (* reached non-octal *) ELSE BEGIN sum := sum*8 + Ord(src[i]) - #60 ; i := i + 1 ; ok := (i <= Length(src)) (* exit test *) END ; MkOctal := sum END ; (*-MkOctal-*) PROCEDURE DoEscChr( OctalStr: String ) ; (* try to set a new CONNECT escape character *) (* OctalStr contains the string representation of the octal number *) VAR val: Integer ; (* The escape character's ordinal *) BEGIN (*-DoEscChr-*) IF (OctalStr = '') THEN Writeln('?SET ESCAPE requires an octal number') ELSE IF (OctalStr[1] IN ['0'..'7']) THEN BEGIN val := MkOctal( OctalStr ) ; (* Get the value *) IF (val = 0) OR (val > #037) THEN Writeln('%Illegal ESCAPE character value: ', val:1:8) ELSE BEGIN (* set the character and its printable version *) EscapeChr := Chr( val ) ; EscPrint := Chr( val + #100 ) END END (* octal digit *) ELSE Writeln('?Non-Octal digit in SET ESCAPE parameter') END ; (*DoEscChr-*) PROCEDURE DoOnOff(VAR flag: Boolean) ; (*) * For the set feature with menu index see if is * either ON or OFF. If so, set to True or False, resp. * Otherwise write error message and leave alone. (*) VAR val: Integer ; (* Value of table search ON/OFF *) BEGIN (*-DoOnOff-*) ConvUpper( parm ) ; (* MUST be upper case *) IF (parm = '') THEN val := 3 (* not ON/OFF *) ELSE val := UniqueCmdIndex(parm, OnOff, 2) ; CASE val OF 1: flag := True ; (* ON *) 2: flag := False ; (* OFF *) 3: Writeln('%SET ', SetMenu^.Cmd[index], ' requires ON or OFF') ; 4: Writeln('%Ambiguous ON or OFF in SET ', SetMenu^.Cmd[index] ) END ; (* case *) END ; (*-DoOnOff-*) PROCEDURE SetHelp ; (* Provide help information for the command SET ? *) BEGIN (*-SetHelp-*) Writeln ; Writeln('The following features are available with the SET command :') ; Writeln ; Writeln('SPEED Change the PERQ''s line speed') ; Writeln('DEBUG ON|OFF Print debug information') ; Writeln('ESCAPE Change the CONNECT escape character') ; Writeln('WARNING ON|OFF Give warning when overwriting existing files') ; Writeln('LOCAL ON|OFF Echo CONNECT typein locally') ; Writeln('VERBOSE ON|OFF Display Kermit''s actions') ; Writeln('EIGHT-BIT ON|OFF Allow eight bit file transfer');(*[pgt001]*) Writeln END ; (*-SetHelp-*) BEGIN (*-SetParameter-*) (* If the command line is empty, prompt user *) IF (CmdLine = '') THEN BEGIN Write('Kermit-SET', PromptChar) ; Readln( CmdLine ) END ; (* get the first identifier from the line *) dumCh := NextIDString( CmdLine, id, switch ) ; (* and a possible parameter *) dumCh := NextIDString( CmdLine, parm, parmsw ) ; IF (id = '') THEN (* nothing - return *) ELSE IF switch OR parmsw THEN Writeln('%SET does not take switches') ELSE IF (id[1] = '?') THEN SetHelp ELSE BEGIN index := PopUniqueCmdIndex(id, RECAST(SetMenu, pNameDesc) ) ; (* What was the command ? *) CASE index OF 1: DoBaudRate( parm ) ; (* SPEED *) 2: DoOnOff( debug ) ; (* DEBUG *) 3: DoEscChr( parm ) ; (* ESCAPE *) 4: DoOnOff( FileWarning ) ; (* WARNING *) 5: DoOnOff( HalfDuplex ) ; (* LOCAL *) 6: DoOnOff( Verbosity ) ; (* VERBOSE *) 7: DoOnOff( EightBitFile ) ; (* EIGHT-BIT [pgt001]*) 8: Writeln('%Not a SET feature: ', id) ; 9: Writeln('%Ambiguous SET feature: ', id) END ; (* case *) END (* else *) END ; (*-SetParameter-*) PROCEDURE DoShow ; (* Show the Kermit flags and parameters *) VAR flag: ARRAY [Boolean] OF String[3] ; (* OF or OFF *) id: String ; (* identifier *) switch: Boolean ; (* SHOW /xxx flag *) i: Integer ; (* Index *) PROCEDURE Feature( index: Integer ) ; (* write a single feature - Index into SetMenu *) BEGIN (*-Index-*) CASE index OF 1: Writeln('Baud rate ', BaudRate) ; 2: Writeln('Debug ', flag[debug]) ; 3: Writeln('Escape chr ^', EscPrint,' (Octal ', Ord(EscapeChr):1:8, ')') ; 4: Writeln('Warning ', flag[FileWarning]) ; 5: Writeln('Local ', flag[HalfDuplex]) ; 6: Writeln('Verbose ', flag[Verbosity]) ; 7: Writeln('Eight-Bit ', flag[EightBitFile]) (*[pgt001]*) END (* case *) END ; (*-Feature-*) BEGIN (*-DoShow-*) Writeln ; flag[True] := 'ON' ; flag[False]:= 'OFF' ; (* get the show feature *) dumCh := NextIDString(CmdLine, id, switch) ; IF (id = '') THEN id := 'ALL' ; (* Default *) IF switch THEN Writeln('%SHOW does not take switches') ELSE IF (id[1] = '?') THEN (* simple help *) BEGIN Writeln('One of the following :-') ; WITH SetMenu^ DO FOR i := 1 TO ShowCount DO (* include 'ALL' *) Writeln( Cmd[i] ) END ELSE (* find feature's index *) BEGIN (* add 'ALL' to the search *) SetMenu^.numcmds := ShowCount ; i := PopUniqueCmdIndex( id, RECAST(SetMenu, pNameDesc) ) ; SetMenu^.numcmds := SetCount ; IF (i <= SetCount) THEN Feature( i ) ELSE IF (i = ShowCount) THEN BEGIN FOR i := 1 TO SetCount DO Feature(i) END ELSE IF (i = ShowNot) THEN Writeln('?Not a SHOW parameter: ', id) ELSE IF (i = ShowAmbig) THEN Writeln('%Ambiguous SHOW parameter: ', id) END ; (* else *) Writeln END . (*-DoShow-*)