home *** CD-ROM | disk | FTP | other *** search
- (*$C-,V-,U-*)
- Program PibTerm;
-
- (*----------------------------------------------------------------------*)
- (* PibTerm --- Terminal Emulator in Turbo Pascal *)
- (*----------------------------------------------------------------------*)
- (* *)
- (* Author: Philip R. Burns *)
- (* Date: January, 1985 *)
- (* Version: 1.0 *)
- (* Systems: For MS-DOS on IBM PCs and close compatibles only. *)
- (* Note: I have checked these on Zenith 151s under *)
- (* MSDOS 2.1 and IBM PCs under PCDOS 2.0. *)
- (* *)
- (* Overview: This program demonstrates the routines in PIBASYNC.PAS, *)
- (* PIBMENUS.PAS, and PIBDIR.PAS by implementing a simple *)
- (* terminal emulation facility. Ascii and XMODEM file *)
- (* transfer are also implemented using the routines in *)
- (* PIBUPDWN.PAS. *)
- (* *)
- (* The commands and general program use follow that of the *)
- (* popular PC-TALK and QMODEM programs. This program is *)
- (* less feature-laden than either of those, but is does *)
- (* provide enough for you to extend it as you like it. *)
- (* *)
- (* The dialing commands assume Touch-Tone (tm) and Hayes *)
- (* command structure. *)
- (* *)
- (* The Turbo Pascal routine DELAY is used in several *)
- (* places. Please make sure that you defined your CPU's *)
- (* clock cycle properly when installing Turbo Pascal, *)
- (* or features like hanging up the phone or checking for *)
- (* time-outs may fail. *)
- (* *)
- (* There are also a couple of routines in the ASYNC package *)
- (* that use CPU loops for timing. These are based upon a *)
- (* 4.77 Mhz clock. If yours differs, you will need to *)
- (* adjust those loops as well. *)
- (* *)
- (* Suggestions for improvements or corrections are welcome. *)
- (* Please leave messages on Gene Plantz's BBS (312) 882 4145 *)
- (* or Ron Fox's BBS (312) 940 6496. *)
- (* *)
- (* Please feel free to add new features. I wrote this *)
- (* program to give people a useful and usable basic terminal *)
- (* facility, and to show how Turbo Pascal can be used for *)
- (* asynchronous communications, menu display, windowing, and *)
- (* so on. I hope that you find this program useful -- and, *)
- (* if you expand upon it, please upload your extensions so *)
- (* that all of us can enjoy them! *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- (*$IGLOBTYPE.PAS*)
- (*$IASCII.PAS*)
-
- (*----------------------------------------------------------------------*)
- (* Global variable definitions *)
- (*----------------------------------------------------------------------*)
-
- Const
- Two_Seconds = 2000 (* Delay argument for 2 second delay *);
- Tenth_of_a_second = 100 (* 1/10 second delay *);
-
- ForeGround_Color = 11 (* Color for ordinary text *);
- BackGround_Color = 0 (* Usual background color *);
-
- Menu_Text_Color = Cyan (* Color for menu text *);
- Menu_Frame_Color = 14 (* Color for menu frame *);
-
- Var
- Local_Echo : Boolean (* Local Echo ON/OFF *);
- BS_Char : Char (* Char to send when Back Space hit *);
- Ctrl_BS_Char : Char (* Char to send when CTRL BS hit *);
- Silent_Mode : Boolean (* TRUE to suppress Ctrl-G bells *);
- Phone_Number : STRING[40] (* Phone number to dial *);
-
- (*----------------------------------------------------------------------*)
- (* Global communications variables *)
- (*----------------------------------------------------------------------*)
-
- Var
- Data_Bits : 5..8;
- Parity : Char;
- Stop_Bits : 0..2;
- Comm_Port : 1..2;
- Baud_Rate : 110..9600;
-
- (*----------------------------------------------------------------------*)
- (* Global variables for view file/directory *)
- (*----------------------------------------------------------------------*)
-
- Var
- View_Count : Integer;
- View_Line : String[128];
- View_Done : Boolean;
- View_Char : String[1];
- View_Y : Integer;
-
- (*----------------------------------------------------------------------*)
- (* Types and Variables for Terminal Emulation Facilities *)
- (*----------------------------------------------------------------------*)
-
- Type
- Terminal_Type = ( Dumb, VT52 );
-
- Var
- Terminal_To_Emulate : Terminal_Type;
-
- (*$IMINMAX.PAS *)
- (*$IPIBASYNC.PAS *)
- (*$IPIBMENUS.PAS *)
- (*$IPIBUPDWN.PAS *)
- (*$IPIBDIR.PAS *)
- (*$ISETPARMS.PAS *)
-
- (*----------------------------------------------------------------------*)
- (* Display_Commands --- Display Command List *)
- (*----------------------------------------------------------------------*)
-
- Procedure Display_Commands( FirstTime : Boolean );
-
- (* *)
- (* Procedure: Display_Commands *)
- (* *)
- (* Purpose: Displays Command List *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Display_Commands( FirstTime : Boolean ); *)
- (* *)
- (* FirstTime --- TRUE for first call, else FALSE *)
- (* *)
- (* Calls: ClrScr *)
- (* KeyPressed *)
- (* Async_Send *)
- (* Restore_Screen *)
- (* Save_Screen *)
- (* Draw_Menu_Frame *)
-
- Var
- Ch: Char;
-
- Begin (* Display_Commands *)
-
- Async_Send( CHR( XOFF ) ); (* Tell host to stop sending *)
- Save_Screen( Saved_Screen ); (* Save current screen image *)
- (* Display help information *)
-
- Draw_Menu_Frame( 5, 2, 75, 24, Menu_Frame_Color, Menu_Text_Color,
- ' Available Commands ' );
- Writeln(' ');
- Writeln(' Alt-B: Send Break');
- Writeln(' Alt-C: Clear Screen');
- Writeln(' Alt-D: Dial a number (Hayes-like modems only)');
- Write (' Alt-E: Turn local echo ON/OFF ');
- If Local_Echo Then
- Writeln('(Currently ON)')
- Else
- Writeln('(Currently OFF)');
- Writeln(' Alt-H: Hang up the phone (Hayes-like modems only)');
- Writeln(' Alt-L: Change logged drive');
- Writeln(' Alt-O: Change subdirectory');
- Writeln(' Alt-P: Set communications parameters');
- Write (' Alt-S: Toggle Silent Mode ');
- If Silent_Mode Then
- Writeln('(Currently ON)')
- Else
- Writeln('(Currently OFF)');
- Writeln(' Alt-Q: Redial last number dialed');
- Writeln(' Alt-V: View a file');
- Writeln(' Alt-W: View current disk directory');
- Writeln(' Alt-X: Leave Program');
- Writeln(' Alt-Y: Delete a file');
- Writeln(' Alt-Z: Produce this command list');
- Writeln(' PgUp: Send file to another computer (upload)');
- Writeln(' PgDn: Receive file from another computer (download)');
- Writeln;
-
- If FirstTime Then
- Write('Hit any key to start terminal emulation.')
- Else
- Write('Hit any key to return to terminal emulation.');
-
- (* Wait for key to be hit *)
- Repeat
- ;
- Until KeyPressed;
- (* Get rid of the character read *)
- Read( Kbd, Ch ); (* Read 2 chars if 1st was ESC *)
- If Ch = CHR( ESC ) Then Read( Kbd, Ch );
-
- (* Restore previous screen image *)
- Restore_Screen( Saved_Screen );
-
- (* Tell host to continue sending *)
- Async_Send( CHR( XON ) );
-
- (* Reset global colors *)
- Reset_Global_Colors;
-
- End (* Display_Commands *);
-
- (*----------------------------------------------------------------------*)
- (* Dial_A_Number --- dial number using Hayes command *)
- (*----------------------------------------------------------------------*)
-
- Procedure Dial_A_Number( Re_Dial : Boolean );
-
- (* *)
- (* Procedure: Dial_A_Number *)
- (* *)
- (* Purpose: Dials phone number using Hayes command *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Dial_A_Number( Re_Dial : Boolean ); *)
- (* *)
- (* Re_Dial --- TRUE to re-dial last number *)
- (* *)
- (* Calls: Async_Send_String *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* Async_Carrier_Detect *)
- (* *)
- (* Remarks: *)
- (* *)
- (* The Hayes modem ATDT command is used. *)
- (* *)
- (* The check for modem timeout is too crude and needs *)
- (* replacement by a better method. *)
- (* *)
-
- Var
- Dial_Title : String[20];
- OK_Redial : Boolean;
- Ch : Char;
- Timed_Out : Boolean;
- Ticks : Integer;
- Tocks : Integer;
-
- Begin (* Dial_A_Number *)
-
- OK_Redial := Re_Dial AND ( Phone_Number <> '' );
-
- If OK_Redial Then
- Dial_Title := 'Redialing'
- Else
- Dial_Title := 'Dialing';
-
- Save_Screen( Saved_Screen );
- Draw_Menu_Frame( 10, 10, 55, 15, Menu_Frame_Color,
- Menu_Text_Color, Dial_Title );
-
- If NOT OK_Redial Then
- Begin
- Writeln;
- Write('Enter number to dial: ');
- Readln( Phone_Number );
- End;
-
- If LENGTH( Phone_Number ) > 0 Then
- Begin
-
- If OK_Redial Then
- Write('*** Re-dialing ... ', Phone_Number )
- Else
- Write('*** Dialing ... ', Phone_Number );
-
- Async_Send_String( 'ATDT' + Phone_Number + CHR( CR ) );
-
- Ticks := Async_Loops_Per_Sec;
- Tocks := 12;
-
- Repeat
- Ticks := Ticks - 1;
- If Ticks = 0 Then
- Begin
- Tocks := Tocks - 1;
- Ticks := Async_Loops_Per_Sec;
- End;
- Timed_Out := ( Tocks = 0 );
- Until ( Async_Carrier_Detect ) OR
- ( Timed_Out ) OR KeyPressed;
-
- End;
-
- If KeyPressed Then
- Begin
-
- GoToXY( 1 , WhereY );
-
- Write('*** Key Pressed, Dialing Aborted.');
-
- While KeyPressed Do
- Read( Kbd , Ch );
-
- Delay( Two_Seconds );
-
- Async_Send_String('+++');
-
- Delay( Two_Seconds );
-
- Async_Send_String( 'ATH0' + CHR( CR ) );
-
- Delay( Two_Seconds );
-
- End
- Else If Timed_Out Then
- Begin
-
- GoToXY( 1 , WhereY );
-
- Write('*** Modem Timed Out, Dialing Aborted.');
-
- Delay( Two_Seconds );
-
- End;
-
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- End (* Dial_A_Number *);
-
- (*----------------------------------------------------------------------*)
- (* Get_File_Size --- Get size in bytes for a file *)
- (*----------------------------------------------------------------------*)
-
- Function Get_File_Size( Fname: AnyStr; Var OpenOK : Boolean ): Real;
-
- (* *)
- (* Procedure: Get_File_Size *)
- (* *)
- (* Purpose: Get size in bytes for a file *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Fsize := Get_File_Size( Fname : AnyStr; *)
- (* Var OpenOK : Boolean ) : Real; *)
- (* *)
- (* Fname --- name of file to find size of *)
- (* OpenOK --- set TRUE if file opened successfully *)
- (* Fsize --- file size in bytes *)
- (* *)
- (* Calls: *)
- (* *)
- (* Reset *)
- (* IoResult *)
- (* Assign *)
- (* LongFileSize *)
- (* Close *)
- (* *)
- (* Remarks: *)
- (* *)
- (* The file must not already be opened before calling this *)
- (* routine. *)
- (* *)
-
- Var
- F : File Of Byte;
-
- Begin (* Get_File_Size *)
-
- Get_File_Size := 0.0;
-
- Assign( F , Fname );
- (*$I- *)
- Reset( F );
- (*$I+ *)
-
- If IoResult = 0 Then
- Begin
- Get_File_Size := LongFileSize( F );
- Close( F );
- OpenOK := TRUE;
- End
- Else
- OpenOK := FALSE;
-
- End (* Get_File_Size *);
-
- (*----------------------------------------------------------------------*)
- (* View_Prompt --- prompt for end-of-screen *)
- (*----------------------------------------------------------------------*)
-
- Procedure View_Prompt( Var View_Done : Boolean; Var View_Count : Integer );
-
- (* *)
- (* Procedure: View_Prompt *)
- (* *)
- (* Purpose: Issues end-of-screen prompt for view routines *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* View_Prompt( Var View_Done : Boolean; *)
- (* Var View_Count : Integer ); *)
- (* *)
- (* View_Done --- TRUE if Stop option selected here *)
- (* View_Count --- Count of lines per panel. May be changed *)
- (* here if C option selected. *)
- (* *)
- (* Calls: RvsVideoOn *)
- (* RvsVideoOff *)
- (* *)
- (* Called by: *)
- (* *)
- (* View_A_File *)
- (* View_A_Directory *)
- (* *)
-
- Begin (* View_Prompt *)
-
- View_Count := 0;
- View_Y := WhereY;
-
- Repeat
-
- GoToXY( 1 , View_Y );
- ClrEol;
-
- RvsVideoOn( Menu_Text_Color , BackGround_Color );
-
- Write('Enter CR to continue, S to stop, ',
- 'C to continue non-stop: ');
-
- RvsVideoOff( Menu_Text_Color , BackGround_Color );
-
- While ( NOT KeyPressed ) Do ;
-
- Read( Kbd, View_Char );
-
- If LENGTH( View_Char ) > 0 Then
- If View_Char[1] <> CHR(ESC) Then
- Begin
- Write( View_Char[1] );
- View_Char := UPCASE( View_Char[1] );
- End
- Else
- Begin
- Read( Kbd , View_Char );
- View_Char := UPCASE( View_Char[1] );
- End
- Else
- View_Char := ' ';
-
- Until( View_Char[1] IN ['S', 'C', ' '] );
-
- Case View_Char[1] Of
- 'C': View_Count := -MaxInt;
- 'S': View_Done := TRUE;
- Else
- ;
- End (* Case *);
-
- GoToXY( 1 , View_Y );
- ClrEol;
- GoToXY( 1 , View_Y );
-
- End (* View_Prompt *);
-
- (*----------------------------------------------------------------------*)
- (* View_A_File --- List ascii file *)
- (*----------------------------------------------------------------------*)
-
- Procedure View_A_File;
-
- (* *)
- (* Procedure: View_A_File *)
- (* *)
- (* Purpose: Lists selected ascii file *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* View_A_File; *)
- (* *)
- (* Calls: View_Prompt *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
- (* Remarks: *)
- (* *)
- (* This routine will list non-ascii files, but they will be *)
- (* meaningless. *)
- (* *)
-
- Var
- View_File_Name : String[15];
- ViewFile : Text;
- View_File_Open : Boolean;
- View_File_Size : Real;
-
- Begin (* View_A_File *)
- (* Draw view menu *)
-
- Save_Screen( Saved_Screen );
- Draw_Menu_Frame( 5, 4, 75, 25, Menu_Frame_Color,
- Menu_Text_Color, 'View A File' );
-
- (* Get name of file to list *)
- Writeln;
- Write('Enter name of file to list: ');
- Readln( View_File_Name );
-
- View_File_Open := FALSE;
-
- (* Ensure file exists ... *)
- If LENGTH( View_File_Name ) > 0 Then
- Begin (* View_File_Name > 0 *)
-
- View_File_Size := Get_File_Size( View_File_Name , View_File_Open );
-
-
- If ( NOT View_File_Open ) Then
- Begin (* IOResult <> 0 *)
- TextColor( Menu_Text_Color + Blink );
- Writeln('>>> Can''t open file ',View_File_Name,' for viewing.');
- Delay( 2000 );
- TextColor( Menu_Text_Color );
- End (* IOResult <> 0 *)
-
- (* ... and file is not empty *)
-
- Else If ( View_File_Size <= 0 ) Then
- Begin (* File is empty *)
- TextColor( Menu_Text_Color + Blink );
- Writeln('>>> File ',View_File_Name,' is empty.');
- Delay( 2000 );
- TextColor( Menu_Text_Color );
- End (* File is empty *)
-
- Else (* Write header line *)
- Begin (* List the File *)
-
- Assign( ViewFile, View_File_Name );
- Reset( ViewFile );
-
- ClrScr;
-
- RvsVideoOn( Menu_Text_Color , BackGround_Color );
-
- Writeln('LISTING OF FILE: ',View_File_Name,
- ' SIZE: ', View_File_Size:8:0, ' BYTES.');
-
- RvsVideoOff( Menu_Text_Color , BackGround_Color );
-
- (* Reset window so header doesn't vanish *)
- Window( 7, 6, 74, 24 );
- GoToXY( 1 , WhereY );
-
- (* List the file *)
-
- View_Count := 0;
- View_Done := FALSE;
-
- Repeat
- (* Read and write line from file *)
- Readln ( ViewFile , View_Line );
- If Length( View_Line ) > 65 Then View_Line[0] := CHR( 65 );
- Writeln( View_Line );
-
- (* Increment count of lines displayed *)
- View_Count := View_Count + 1;
-
- (* Prompt if end of screen *)
- If View_Count > 17 Then
- View_Prompt( View_Done , View_Count );
-
- Until EOF( ViewFile ) OR View_Done;
-
- RvsVideoOn( Menu_Text_Color , BackGround_Color );
- Write('Viewing of file complete. ',
- 'Hit any key to continue.');
- RvsVideoOff( Menu_Text_Color , BackGround_Color );
- While ( Not KeyPressed ) Do ;
- Read( Kbd , View_Char[1] );
-
- End (* List the file *);
-
- End (* View_File_Name > 0 *);
-
- If View_File_Open Then Close( ViewFile );
-
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- End (* View_A_File *);
-
- (*----------------------------------------------------------------------*)
- (* View_Directory --- List files in current directory *)
- (*----------------------------------------------------------------------*)
-
- Procedure View_Directory;
-
- (* *)
- (* Procedure: View_Directory *)
- (* *)
- (* Purpose: Lists files in current MSDOS directory *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* View_Directory; *)
- (* *)
- (* Calls: View_Prompt *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* Dir_Get_Default_Drive *)
- (* Dir_Get_Current_Path *)
- (* Dir_Find_First_File *)
- (* Dir_Find_Next_File *)
- (* Dir_Convert_Time *)
- (* Dir_Convert_Date *)
- (* *)
-
- Var
- View_Directory_Name : AnyStr;
- Drive_Ch : Char;
- Iok : Integer;
- File_Entry : Directory_Record;
- S_File_Name : String[14];
- S_File_Time : String[8];
- S_File_Date : String[8];
- S_File_Size : Real;
- Fs1 : Real;
- Fs2 : Real;
- I : Integer;
-
- Begin (* View_Directory *)
- (* Draw view menu *)
-
- Save_Screen( Saved_Screen );
- Draw_Menu_Frame( 5, 4, 75, 25, Menu_Frame_Color,
- Menu_Text_Color, 'View Current Directory' );
-
- ClrScr;
-
- RvsVideoOn( Menu_Text_Color , BackGround_Color );
-
- Drive_Ch := Dir_Get_Default_Drive;
-
- Iok := Dir_Get_Current_Path( Drive_Ch , View_Directory_Name );
-
- Writeln('LISTING OF DIRECTORY: ',Drive_Ch + ':\' + View_Directory_Name );
-
- RvsVideoOff( Menu_Text_Color , BackGround_Color );
-
- (* Reset window so header doesn't vanish *)
- Window( 7, 6, 74, 24 );
- GoToXY( 1 , WhereY );
-
- (* List the directory contents *)
-
- View_Count := 0;
- View_Done := ( Dir_Find_First_File( '*.*', File_Entry ) <> 0 );
-
- Repeat
- (* Display Next Directory Entry *)
-
- S_File_Name := '';
- I := 1;
-
- While( ( I <= 14 ) AND ( File_Entry.File_Name[I] <> CHR(0) ) ) Do
- Begin
- S_File_Name := S_File_Name + File_Entry.File_Name[I];
- I := I + 1;
- End;
-
- Dir_Convert_Time( File_Entry.File_Time , S_File_Time );
- Dir_Convert_Date( File_Entry.File_Date , S_File_Date );
-
- Fs1 := File_Entry.File_Size[1];
- Fs2 := File_Entry.File_Size[2];
-
- If Fs1 < 0 Then Fs1 := Fs1 + 65536.0;
- If Fs2 < 0 Then Fs2 := Fs2 + 65536.0;
-
- S_File_Size := Fs2 * 65536.0 + Fs1;
-
- Writeln( S_File_Name:14, ' ', S_File_Size:8:0, ' ', S_File_Date, ' ',
- S_File_Time );
-
- (* Increment count of lines displayed *)
- View_Count := View_Count + 1;
-
- (* Prompt if end of screen *)
- If View_Count > 17 Then
- View_Prompt( View_Done , View_Count );
-
- If NOT View_Done Then
- View_Done := ( Dir_Find_Next_File( File_Entry ) <> 0 );
-
- Until View_Done;
-
- (* Issue final end-of-directory prompt *)
- RvsVideoOn( Menu_Text_Color , BackGround_Color );
-
- Write('Viewing of directory complete. ',
- 'Hit any key to continue.');
-
- RvsVideoOff( Menu_Text_Color , BackGround_Color );
-
- While ( NOT KeyPressed ) Do ;
-
- Read( Kbd , View_Char );
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- End (* View_Directory *);
-
-
-
- (*----------------------------------------------------------------------*)
- (* Log_Drive_Change --- Change current logged drive *)
- (*----------------------------------------------------------------------*)
-
- Procedure Log_Drive_Change;
-
- (* *)
- (* Procedure: Log_Drive_Change *)
- (* *)
- (* Purpose: Change current logged drive *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Log_Drive_Change *)
- (* *)
- (* Calls: Dir_Get_Default_Drive *)
- (* Dir_Set_Default_Drive *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
- (* *)
-
- Var
- Drive_Ch : String[1];
- Drive_No : Integer;
- Drive_Count : Integer;
-
- Begin (* Log_Drive_Change *);
-
- (* Draw log change menu *)
-
- Save_Screen( Saved_Screen );
- Draw_Menu_Frame( 5, 10, 75, 15, Menu_Frame_Color,
- Menu_Text_Color, 'Change Current Logged Drive' );
-
- ClrScr;
-
- GoToXY( 1 , 1 );
- Drive_Ch[1] := Dir_Get_Default_Drive;
-
- Writeln('Current logged drive is ',Drive_Ch[1] );
-
- GoToXY( 1 , 2 );
-
- Write('Enter letter for new logged drive: ');
-
- Read( Kbd , Drive_Ch );
- Write( Drive_Ch );
-
- If LENGTH( Drive_Ch ) = 0 Then
- Begin
- Writeln;
- Writeln('*** Logged drive remains unchanged.')
- End
- Else
- Begin
- (* Figure no. of drives in system *)
- Drive_Count := Dir_Count_Drives;
-
- (* Drive no. for entered letter *)
- Drive_No := ORD( UpCase( Drive_Ch ) ) - ORD( 'A' );
-
- (* Check if drive legitimate *)
-
- If ( Drive_No < 0 ) OR ( Drive_No > Drive_Count ) Then
- Writeln('*** Invalid drive, logged drive unchanged.')
- Else
- Begin
- (* Change default drive *)
- Dir_Set_Default_Drive( Drive_Ch );
-
- Writeln;
- Writeln('*** Logged drive changed to ',Drive_Ch );
-
- End;
-
- End;
-
- Delay( 2000 );
-
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- End (* Log_Drive_Change *);
-
- (*----------------------------------------------------------------------*)
- (* Change_Subdirectory --- Change current disk subdirectory *)
- (*----------------------------------------------------------------------*)
-
- Procedure Change_Subdirectory;
-
- (* *)
- (* Procedure: Change_Subdirectory *)
- (* *)
- (* Purpose: Change current subdirectory *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Change_Subdirectory; *)
- (* *)
- (* Calls: Dir_Get_Default_Drive *)
- (* Dir_Set_Current_Path *)
- (* Dir_Get_Current_Path *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
- (* *)
-
- Var
- Path_Name : AnyStr;
- Iok : Integer;
- Drive_Ch : Char;
-
- Begin (* Change_Subdirectory *)
- (* Draw directory change menu *)
-
- Save_Screen( Saved_Screen );
- Draw_Menu_Frame( 5, 10, 75, 15, Menu_Frame_Color,
- Menu_Text_Color, 'Change Current Directory' );
-
- ClrScr;
-
- GoToXY( 1 , 1 );
-
- Drive_Ch := Dir_Get_Default_Drive;
-
- Iok := Dir_Get_Current_Path( Drive_Ch , Path_Name );
-
- Writeln('Current directory is ', Drive_Ch + ':\' + Path_Name );
-
- Write('Enter name of new directory path: ');
-
- Read( Path_Name );
- Writeln;
-
- If LENGTH( Path_Name ) = 0 Then
- Writeln('*** Current directory remains unchanged.')
- Else
- Begin
-
- If Dir_Set_Current_Path( Path_Name ) = 0 Then
- Writeln('*** Current directory changed to ',
- Drive_Ch + ':' + Path_Name )
- Else
- Writeln('*** Error found, directory not changed');
- End;
-
- Delay( 2000 );
-
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- End (* Change_Subdirectory *);
-
- (*----------------------------------------------------------------------*)
- (* Delete_A_File --- Delete a file *)
- (*----------------------------------------------------------------------*)
-
- Procedure Delete_A_File;
-
- (* *)
- (* Procedure: Delete_A_File *)
- (* *)
- (* Purpose: Delete file in current subdirectory *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Delete_A_File; *)
- (* *)
- (* Calls: Dir_Delete_File *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
-
- Var
- File_Name : AnyStr;
-
- Begin (* Delete_A_File *)
- (* Draw delete file menu *)
-
- Save_Screen( Saved_Screen );
- Draw_Menu_Frame( 5, 10, 75, 14, Menu_Frame_Color,
- Menu_Text_Color, 'Delete A File' );
-
- ClrScr;
-
- GoToXY( 1 , 1 );
-
- Write('Enter name of file to delete: ');
-
- Read( File_Name );
- Writeln;
-
- If LENGTH( File_Name ) = 0 Then
- Writeln('*** No file to delete.')
- Else
- If ( Dir_Delete_File( File_Name ) = 0 ) Then
- Writeln('*** File deleted.')
- Else
- Writeln('*** File not found to delete or read-only');
-
- Delay( 2000 );
-
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- End (* Delete_A_File *);
-
- (*----------------------------------------------------------------------*)
- (* Fast_Change_Params --- fast change of communications params. *)
- (*----------------------------------------------------------------------*)
-
- Procedure Fast_Change_Params;
-
- (* *)
- (* Procedure: Fast_Change_Params *)
- (* *)
- (* Purpose: Fast change of communications params *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Fast_Change_Params; *)
- (* *)
- (* *)
- (* Remarks: *)
- (* *)
- (* This routine is useful is making a fast switch between *)
- (* the parameter values needed by XMODEM and those required *)
- (* by the remote host. *)
- (* *)
-
- Const
- Comm_Parities : Array[ 1 .. 6 ] Of Char = ('E','N','O','E','N','O');
- Comm_Data_Bits : Array[ 1 .. 6 ] Of Integer = ( 7, 7, 7, 8, 8, 8 );
-
- Var
- Comm_Parms_Menu : Menu_Type;
- Comm_Parms : Integer;
- OK_Setup : Boolean;
- I : Integer;
-
- Begin (* Fast_Change_Params *)
-
- Comm_Parms_Menu.Menu_Size := 6;
- Comm_Parms_Menu.Menu_Default := 5;
- Comm_Parms_Menu.Menu_Row := 11;
- Comm_Parms_Menu.Menu_Column := 30;
- Comm_Parms_Menu.Menu_Tcolor := Menu_Text_Color;
- Comm_Parms_Menu.Menu_Bcolor := BackGround_Color;
- Comm_Parms_Menu.Menu_Fcolor := Menu_Frame_Color;
- Comm_Parms_Menu.Menu_Width := 0;
- Comm_Parms_Menu.Menu_Height := 0;
-
- For I := 1 To 6 Do
- With Comm_Parms_Menu.Menu_Entries[I] Do
- Begin
- Menu_Item_Row := I;
- Menu_Item_Column := 2;
- Case I Of
- 1: Menu_Item_Text := 'Even parity, 7 bits, 1 stop';
- 2: Menu_Item_Text := 'No parity, 7 bits, 1 stop';
- 3: Menu_Item_Text := 'Odd parity, 7 bits, 1 stop';
- 4: Menu_Item_Text := 'Even parity, 8 bits, 1 stop';
- 5: Menu_Item_Text := 'No parity, 8 bits, 1 stop (Xmodem)';
- 6: Menu_Item_Text := 'Odd parity, 8 bits, 1 stop';
- End (* Case *);
- End;
-
- Comm_Parms_Menu.Menu_Title := 'Choose new communications parameters: ';
-
- Menu_Display_Choices( Comm_Parms_Menu );
- Comm_Parms := Menu_Get_Choice( Comm_Parms_Menu , Erase_Menu );
-
- Parity := Comm_Parities[ Comm_Parms ];
- Data_Bits := Comm_Data_Bits[ Comm_Parms ];
-
- OK_Setup := Async_Open( Comm_Port, Baud_Rate, Parity, Data_Bits, 1 );
-
- End (* Fast_Change_Params *);
-
- (*----------------------------------------------------------------------*)
- (* Process_Command --- Process PibTerm command *)
- (*----------------------------------------------------------------------*)
-
- Procedure Process_Command( Var Done: Boolean;
- Var Ch : Char;
- Use_Ch : Boolean );
-
- (* *)
- (* Procedure: Process_Command *)
- (* *)
- (* Purpose: Process PibTerm Command escape sequence *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Process_Command( Var Done : Boolean; Var Ch: Char; *)
- (* Use_Ch: Boolean ); *)
- (* *)
- (* Done --- set TRUE if termination command (Alt-X) found *)
- (* Ch --- character following ESC *)
- (* Use_Ch --- TRUE if Ch on entry is char following ESC, *)
- (* FALSE if Ch to be read here. *)
- (* *)
- (* Calls: Async_Send_String *)
- (* Dial_A_Number *)
- (* Async_Send_Break *)
- (* Async_Carrier_Detect *)
- (* Display_Commands *)
- (* Delay *)
- (* UpLoad *)
- (* DownLoad *)
- (* Get_File_Transfer_Protocol *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Fast_Change_Params *)
- (* Delete_A_File *)
- (* *)
- (* Remarks: *)
- (* *)
- (* All PibTerm commands are implemented as escape sequences, *)
- (* very much like PC-TALK or QMODEM. The available commands *)
- (* are: *)
- (* *)
- (* Alt-B: Send Break *)
- (* Alt-C: Clear Screen *)
- (* Alt-D: Dial a number (Hayes-like modems only) *)
- (* Alt-E: Turn local echo ON/OFF *)
- (* Alt-F: Fast change of communications params *)
- (* Alt-H: Hang up the phone (Hayes-like modems only) *)
- (* Alt-L: Log Drive Change *)
- (* Alt-O: Change Subdirectory *)
- (* Alt-P: Set communications parameters *)
- (* Alt-Q: Redial last number dialed *)
- (* Alt-S: Toggle Silent Mode *)
- (* Alt-V: View a file *)
- (* Alt-W: View disk directory *)
- (* Alt-X: Leave Program *)
- (* Alt-Y: Delete a file *)
- (* Alt-Z: Produce this command list *)
- (* PgUp: Upload a file *)
- (* PgDn: Download a file *)
- (* *)
-
- Var
- YesNo : Char;
- Flag : Boolean;
-
- Begin (* Process_Command *)
-
- (* Pick up character following escape *)
- If NOT Use_Ch Then Read( Kbd , Ch );
-
- (* Interpret it *)
-
- Case ORD( Ch ) Of
-
- 16: Dial_A_Number( TRUE );
-
- 17: View_Directory;
-
- 18: Begin (* Turn Local Echo On/Off *)
-
- Local_Echo := NOT Local_Echo;
-
- Save_Screen( Saved_Screen );
- Draw_Menu_Frame( 10, 10, 55, 15, Menu_Frame_Color,
- Menu_Text_Color, '' );
-
- Case Local_Echo OF
-
- TRUE: Begin
- Writeln;
- Writeln('*** Local echo now ON');
- End;
-
- FALSE: Begin
- Writeln;
- Writeln('*** Local echo now OFF');
- End;
-
- End (* Case *);
-
- Delay( 2000 );
-
- Restore_Screen( Saved_Screen );
-
- Reset_Global_Colors;
-
- End (* Turn Local Echo On/Off *);
-
- 21: Delete_A_File;
-
- 24: Change_Subdirectory;
-
- 25: Flag := Set_Params( FALSE );
-
- 31: Begin (* Turn Silent Mode On/Off *)
-
- Silent_Mode := NOT Silent_Mode;
-
- Save_Screen( Saved_Screen );
- Draw_Menu_Frame( 10, 10, 55, 15, Menu_Frame_Color,
- Menu_Text_Color, '' );
-
- Case Silent_Mode OF
-
- TRUE: Begin
- Writeln;
- Writeln('*** Silent Mode now ON');
- End;
-
- FALSE: Begin
- Writeln;
- Writeln('*** Silent Mode now OFF');
- End;
-
- End (* Case *);
-
- Delay( 2000 );
-
- Restore_Screen( Saved_Screen );
-
- Reset_Global_Colors;
-
- End (* Turn Silent Mode On/Off *);
-
- 32: Dial_A_Number( FALSE );
-
- 38: Log_Drive_Change;
-
- 33: Fast_Change_Params;
-
- 46: ClrScr;
-
- 48: Begin (* Send_Break *)
- Async_Send_Break;
- End;
-
- 44: Display_Commands( FALSE );
-
- 45: Begin (* Quit *)
-
- Save_Screen( Saved_Screen );
-
- Draw_Menu_Frame( 10, 10, 61, 13, Menu_Frame_Color,
- Menu_Text_Color, '' );
-
- Writeln;
- Write('Are you sure you want to quit (Y/N)? ');
-
- Read( Kbd , YesNo );
- Write( YesNo );
-
- Done := ( YesNo IN ['Y','y'] );
-
- Restore_Screen( Saved_Screen );
-
- Reset_Global_Colors;
-
- End;
-
- 35: Begin (* Hang-up Phone *)
-
- Save_Screen( Saved_Screen );
-
- Draw_Menu_Frame( 10, 10, 50, 15, Menu_Frame_Color,
- Menu_Text_Color, '' );
-
- Writeln;
- Writeln('*** Hanging up the phone ***');
-
- Delay( Two_Seconds );
-
- Async_Send_String('+++');
-
- Delay( Two_Seconds );
-
- Async_Send_String( 'ATH0' + CHR( CR ) );
-
- Delay( Two_Seconds );
-
- If Async_Carrier_Detect Then
- Writeln('*** Phone not hung up, try again ***')
- Else
- Writeln('*** Phone hung up ***');
-
- Delay( 3000 );
-
- Restore_Screen( Saved_Screen );
-
- Reset_Global_Colors;
-
- End (* Hang-up Phone *);
-
- 47: View_A_File;
-
- 73: Begin (* Upload a file *)
- UpLoad( Get_File_Transfer_Protocol('sending file') );
- End (* Upload a file *);
-
- 81: Begin (* Download a file *)
- DownLoad( Get_File_Transfer_Protocol('receiving file') );
- End;
-
- Else
- ;
- End (* Case *);
-
- End (* Process_Command *);
-
- (*----------------------------------------------------------------------*)
- (* Display_Character --- show character received from port *)
- (*----------------------------------------------------------------------*)
-
- Procedure Display_Character( Ch : Char );
-
- (* *)
- (* Procedure: Display_Character *)
- (* *)
- (* Purpose: Displays character received from comm. port *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Display_Character( Ch : Char ); *)
- (* *)
- (* Ch --- Character received from Comm. port. *)
- (* *)
- (* Calls: Async_Receive *)
- (* *)
- (* Remarks: *)
- (* *)
- (* This routine exists to strip out certain characters which *)
- (* should not be displayed, and also to implement the XON/XOFF *)
- (* protocol in a simple-minded manner. *)
- (* *)
-
- Begin (* Display_Character *)
-
- Case ORD( Ch ) Of
-
- NUL : ; (* Strip Nulls *)
- DEL : ; (* Strip Deletes *)
- XON : ; (* Strip unattached XONs *)
-
- XOFF : Begin (* Handle XOFF *)
-
- (* Wait for XON *)
- Repeat
- Delay( Tenth_of_a_second );
- While( NOT Async_Receive( Ch ) ) Do;
- Until( Ch = CHR( XON ) );
-
- End (* Handle XOFF *);
-
- BELL : If Not Silent_Mode Then
- Write( Ch );
-
- Else
- Write( Ch );
-
- End (* Case *);
-
- End (* Display_Character *);
-
- (*$IPIBSCROL.PAS *)
- (*$IPIBVT52.PAS *)
- (*$IPIBDUMBT.PAS *)
-
- (* ------------------------------------------------------------------------ *)
- (* PibTerm --- Main Program *)
- (* ------------------------------------------------------------------------ *)
-
- Begin (* PibTerm *)
- (* Select color/mono screen *)
- Get_Screen_Address( Actual_Screen );
-
- (* Establish colors *)
- Set_Global_Colors( Yellow, Black );
-
- (* Silent mode OFF to start *)
- Silent_Mode := FALSE;
- (* Local echo starts at OFF *)
- Local_Echo := FALSE;
- (* Phone number to dial *)
- Phone_Number := '';
- (* Establish Communications *)
-
- If NOT Set_Params( True ) Then
- Begin
- Writeln('*** Sorry, can''t initialize communications.');
- Writeln('*** Program stops.');
- Halt;
- End;
-
- (* Give Instructions *)
- Display_Commands( TRUE );
-
- (* Begin Terminal Emulation *)
- Case Terminal_To_Emulate Of
- VT52: Emulate_VT52;
- Dumb: Emulate_Dumb_Terminal;
- End (* Case *);
-
- (* End Terminal Emulation *)
- Async_Close;
- (* Clear screen *)
- ClrScr;
-
- End (* PibTerm *).