home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PIBTERM.ZIP / PIBTERM.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-11-26  |  52.8 KB  |  1,337 lines

  1. (*$C-,V-,U-*)
  2. Program PibTerm;
  3.  
  4. (*----------------------------------------------------------------------*)
  5. (*               PibTerm --- Terminal Emulator in Turbo Pascal          *)
  6. (*----------------------------------------------------------------------*)
  7. (*                                                                      *)
  8. (*  Author:   Philip R. Burns                                           *)
  9. (*  Date:     January, 1985                                             *)
  10. (*  Version:  1.0                                                       *)
  11. (*  Systems:  For MS-DOS on IBM PCs and close compatibles only.         *)
  12. (*            Note:  I have checked these on Zenith 151s under          *)
  13. (*                   MSDOS 2.1 and IBM PCs under PCDOS 2.0.             *)
  14. (*                                                                      *)
  15. (*  Overview: This program demonstrates the routines in PIBASYNC.PAS,   *)
  16. (*            PIBMENUS.PAS, and PIBDIR.PAS by implementing a simple     *)
  17. (*            terminal emulation facility.  Ascii and XMODEM file       *)
  18. (*            transfer are also implemented using the routines in       *)
  19. (*            PIBUPDWN.PAS.                                             *)
  20. (*                                                                      *)
  21. (*            The commands and general program use follow that of the   *)
  22. (*            popular PC-TALK and QMODEM programs.  This program is     *)
  23. (*            less feature-laden than either of those, but is does      *)
  24. (*            provide enough for you to extend it as you like it.       *)
  25. (*                                                                      *)
  26. (*            The dialing commands assume Touch-Tone (tm) and Hayes     *)
  27. (*            command structure.                                        *)
  28. (*                                                                      *)
  29. (*            The Turbo Pascal routine DELAY is used in several         *)
  30. (*            places.  Please make sure that you defined your CPU's     *)
  31. (*            clock cycle properly when installing Turbo Pascal,        *)
  32. (*            or features like hanging up the phone or checking for     *)
  33. (*            time-outs may fail.                                       *)
  34. (*                                                                      *)
  35. (*            There are also a couple of routines in the ASYNC package  *)
  36. (*            that use CPU loops for timing.  These are based upon a    *)
  37. (*            4.77 Mhz clock.  If yours differs, you will need to       *)
  38. (*            adjust those loops as well.                               *)
  39. (*                                                                      *)
  40. (*            Suggestions for improvements or corrections are welcome.  *)
  41. (*            Please leave messages on Gene Plantz's BBS (312) 882 4145 *)
  42. (*            or Ron Fox's BBS (312) 940 6496.                          *)
  43. (*                                                                      *)
  44. (*            Please feel free to add new features.  I wrote this       *)
  45. (*            program to give people a useful and usable basic terminal *)
  46. (*            facility, and to show how Turbo Pascal can be used for    *)
  47. (*            asynchronous communications, menu display, windowing, and *)
  48. (*            so on.  I hope that you find this program useful -- and,  *)
  49. (*            if you expand upon it, please upload your extensions so   *)
  50. (*            that all of us can enjoy them!                            *)
  51. (*                                                                      *)
  52. (*----------------------------------------------------------------------*)
  53.  
  54. (*$IGLOBTYPE.PAS*)
  55. (*$IASCII.PAS*)
  56.  
  57. (*----------------------------------------------------------------------*)
  58. (*                   Global variable definitions                        *)
  59. (*----------------------------------------------------------------------*)
  60.  
  61. Const
  62.    Two_Seconds        = 2000       (* Delay argument for 2 second delay *);
  63.    Tenth_of_a_second  =  100       (* 1/10 second delay                 *);
  64.  
  65.    ForeGround_Color   = 11         (* Color for ordinary text           *);
  66.    BackGround_Color   = 0          (* Usual background color            *);
  67.  
  68.    Menu_Text_Color    = Cyan       (* Color for menu text               *);
  69.    Menu_Frame_Color   = 14         (* Color for menu frame              *);
  70.  
  71. Var
  72.    Local_Echo   : Boolean          (* Local Echo ON/OFF                 *);
  73.    BS_Char      : Char             (* Char to send when Back Space hit  *);
  74.    Ctrl_BS_Char : Char             (* Char to send when CTRL BS hit     *);
  75.    Silent_Mode  : Boolean          (* TRUE to suppress Ctrl-G bells     *);
  76.    Phone_Number : STRING[40]       (* Phone number to dial              *);
  77.  
  78. (*----------------------------------------------------------------------*)
  79. (*               Global communications variables                        *)
  80. (*----------------------------------------------------------------------*)
  81.  
  82. Var
  83.    Data_Bits   : 5..8;
  84.    Parity      : Char;
  85.    Stop_Bits   : 0..2;
  86.    Comm_Port   : 1..2;
  87.    Baud_Rate   : 110..9600;
  88.  
  89. (*----------------------------------------------------------------------*)
  90. (*           Global variables for view file/directory                   *)
  91. (*----------------------------------------------------------------------*)
  92.  
  93. Var
  94.    View_Count     : Integer;
  95.    View_Line      : String[128];
  96.    View_Done      : Boolean;
  97.    View_Char      : String[1];
  98.    View_Y         : Integer;
  99.  
  100. (*----------------------------------------------------------------------*)
  101. (*           Types and Variables for Terminal Emulation Facilities      *)
  102. (*----------------------------------------------------------------------*)
  103.  
  104. Type
  105.    Terminal_Type = ( Dumb, VT52 );
  106.  
  107. Var
  108.    Terminal_To_Emulate : Terminal_Type;
  109.  
  110. (*$IMINMAX.PAS   *)
  111. (*$IPIBASYNC.PAS *)
  112. (*$IPIBMENUS.PAS *)
  113. (*$IPIBUPDWN.PAS *)
  114. (*$IPIBDIR.PAS   *)
  115. (*$ISETPARMS.PAS *)
  116.  
  117. (*----------------------------------------------------------------------*)
  118. (*                Display_Commands --- Display Command List             *)
  119. (*----------------------------------------------------------------------*)
  120.  
  121. Procedure Display_Commands( FirstTime : Boolean );
  122.  
  123. (*                                                                      *)
  124. (*     Procedure:  Display_Commands                                     *)
  125. (*                                                                      *)
  126. (*     Purpose:    Displays Command List                                *)
  127. (*                                                                      *)
  128. (*     Calling Sequence:                                                *)
  129. (*                                                                      *)
  130. (*        Display_Commands( FirstTime : Boolean );                      *)
  131. (*                                                                      *)
  132. (*           FirstTime --- TRUE for first call, else FALSE              *)
  133. (*                                                                      *)
  134. (*      Calls:   ClrScr                                                 *)
  135. (*               KeyPressed                                             *)
  136. (*               Async_Send                                             *)
  137. (*               Restore_Screen                                         *)
  138. (*               Save_Screen                                            *)
  139. (*               Draw_Menu_Frame                                        *)
  140.  
  141. Var
  142.    Ch: Char;
  143.  
  144. Begin (* Display_Commands *)
  145.  
  146.    Async_Send( CHR( XOFF ) );     (* Tell host to stop sending *)
  147.    Save_Screen( Saved_Screen );    (* Save current screen image *)
  148.                                    (* Display help information  *)
  149.  
  150.    Draw_Menu_Frame( 5, 2, 75, 24, Menu_Frame_Color, Menu_Text_Color,
  151.                ' Available Commands ' );
  152.    Writeln('                   ');
  153.    Writeln('  Alt-B:  Send Break');
  154.    Writeln('  Alt-C:  Clear Screen');
  155.    Writeln('  Alt-D:  Dial a number (Hayes-like modems only)');
  156.    Write  ('  Alt-E:  Turn local echo ON/OFF ');
  157.    If Local_Echo Then
  158.       Writeln('(Currently ON)')
  159.    Else
  160.       Writeln('(Currently OFF)');
  161.    Writeln('  Alt-H:  Hang up the phone (Hayes-like modems only)');
  162.    Writeln('  Alt-L:  Change logged drive');
  163.    Writeln('  Alt-O:  Change subdirectory');
  164.    Writeln('  Alt-P:  Set communications parameters');
  165.    Write  ('  Alt-S:  Toggle Silent Mode ');
  166.    If Silent_Mode Then
  167.       Writeln('(Currently ON)')
  168.    Else
  169.       Writeln('(Currently OFF)');
  170.    Writeln('  Alt-Q:  Redial last number dialed');
  171.    Writeln('  Alt-V:  View a file');
  172.    Writeln('  Alt-W:  View current disk directory');
  173.    Writeln('  Alt-X:  Leave Program');
  174.    Writeln('  Alt-Y:  Delete a file');
  175.    Writeln('  Alt-Z:  Produce this command list');
  176.    Writeln('  PgUp:   Send file to another computer (upload)');
  177.    Writeln('  PgDn:   Receive file from another computer (download)');
  178.    Writeln;
  179.  
  180.    If FirstTime Then
  181.       Write('Hit any key to start terminal emulation.')
  182.    Else
  183.       Write('Hit any key to return to terminal emulation.');
  184.  
  185.                                    (* Wait for key to be hit        *)
  186.    Repeat
  187.       ;
  188.    Until KeyPressed;
  189.                                    (* Get rid of the character read *)
  190.    Read( Kbd, Ch );                (* Read 2 chars if 1st was ESC   *)
  191.    If Ch = CHR( ESC ) Then Read( Kbd, Ch );
  192.  
  193.                                    (* Restore previous screen image *)
  194.    Restore_Screen( Saved_Screen );
  195.  
  196.                                    (* Tell host to continue sending *)
  197.    Async_Send( CHR( XON ) );
  198.  
  199.                                    (* Reset global colors           *)
  200.    Reset_Global_Colors;
  201.  
  202. End   (* Display_Commands *);
  203.  
  204. (*----------------------------------------------------------------------*)
  205. (*           Dial_A_Number --- dial number using Hayes command          *)
  206. (*----------------------------------------------------------------------*)
  207.  
  208. Procedure Dial_A_Number( Re_Dial : Boolean );
  209.  
  210. (*                                                                      *)
  211. (*     Procedure:  Dial_A_Number                                        *)
  212. (*                                                                      *)
  213. (*     Purpose:    Dials phone number using Hayes command               *)
  214. (*                                                                      *)
  215. (*     Calling Sequence:                                                *)
  216. (*                                                                      *)
  217. (*        Dial_A_Number( Re_Dial : Boolean );                           *)
  218. (*                                                                      *)
  219. (*           Re_Dial --- TRUE to re-dial last number                    *)
  220. (*                                                                      *)
  221. (*     Calls:   Async_Send_String                                       *)
  222. (*              Save_Screen                                             *)
  223. (*              Restore_Screen                                          *)
  224. (*              Draw_Menu_Frame                                         *)
  225. (*              Reset_Global_Colors                                     *)
  226. (*              Async_Carrier_Detect                                    *)
  227. (*                                                                      *)
  228. (*     Remarks:                                                         *)
  229. (*                                                                      *)
  230. (*        The Hayes modem ATDT command is used.                         *)
  231. (*                                                                      *)
  232. (*        The check for modem timeout is too crude and needs            *)
  233. (*        replacement by a better method.                               *)
  234. (*                                                                      *)
  235.  
  236. Var
  237.    Dial_Title : String[20];
  238.    OK_Redial  : Boolean;
  239.    Ch         : Char;
  240.    Timed_Out  : Boolean;
  241.    Ticks      : Integer;
  242.    Tocks      : Integer;
  243.  
  244. Begin (* Dial_A_Number *)
  245.  
  246.    OK_Redial := Re_Dial AND ( Phone_Number <> '' );
  247.  
  248.    If OK_Redial Then
  249.       Dial_Title := 'Redialing'
  250.    Else
  251.       Dial_Title := 'Dialing';
  252.  
  253.    Save_Screen( Saved_Screen );
  254.    Draw_Menu_Frame( 10, 10, 55, 15, Menu_Frame_Color,
  255.                     Menu_Text_Color, Dial_Title );
  256.  
  257.    If NOT OK_Redial Then
  258.       Begin
  259.          Writeln;
  260.          Write('Enter number to dial: ');
  261.          Readln( Phone_Number );
  262.       End;
  263.  
  264.    If LENGTH( Phone_Number ) > 0 Then
  265.       Begin
  266.  
  267.          If OK_Redial Then
  268.             Write('*** Re-dialing ... ', Phone_Number )
  269.          Else
  270.             Write('*** Dialing ... ', Phone_Number );
  271.  
  272.          Async_Send_String( 'ATDT' + Phone_Number + CHR( CR ) );
  273.  
  274.          Ticks := Async_Loops_Per_Sec;
  275.          Tocks := 12;
  276.  
  277.          Repeat
  278.             Ticks  := Ticks - 1;
  279.             If Ticks = 0 Then
  280.                Begin
  281.                   Tocks := Tocks - 1;
  282.                   Ticks := Async_Loops_Per_Sec;
  283.                End;
  284.             Timed_Out := ( Tocks = 0 );
  285.          Until ( Async_Carrier_Detect ) OR
  286.                ( Timed_Out            ) OR KeyPressed;
  287.  
  288.       End;
  289.  
  290.    If KeyPressed Then
  291.       Begin
  292.  
  293.          GoToXY( 1 , WhereY );
  294.  
  295.          Write('*** Key Pressed, Dialing Aborted.');
  296.  
  297.          While KeyPressed Do
  298.             Read( Kbd , Ch );
  299.  
  300.          Delay( Two_Seconds );
  301.  
  302.          Async_Send_String('+++');
  303.  
  304.          Delay( Two_Seconds );
  305.  
  306.          Async_Send_String( 'ATH0' + CHR( CR ) );
  307.  
  308.          Delay( Two_Seconds );
  309.  
  310.       End
  311.    Else If Timed_Out Then
  312.       Begin
  313.  
  314.          GoToXY( 1 , WhereY );
  315.  
  316.          Write('*** Modem Timed Out, Dialing Aborted.');
  317.  
  318.          Delay( Two_Seconds );
  319.  
  320.       End;
  321.  
  322.    Restore_Screen( Saved_Screen );
  323.    Reset_Global_Colors;
  324.  
  325. End   (* Dial_A_Number *);
  326.  
  327. (*----------------------------------------------------------------------*)
  328. (*           Get_File_Size --- Get size in bytes for a file             *)
  329. (*----------------------------------------------------------------------*)
  330.  
  331. Function Get_File_Size( Fname: AnyStr; Var OpenOK : Boolean ): Real;
  332.  
  333. (*                                                                      *)
  334. (*     Procedure:  Get_File_Size                                        *)
  335. (*                                                                      *)
  336. (*     Purpose:    Get size in bytes for a file                         *)
  337. (*                                                                      *)
  338. (*     Calling Sequence:                                                *)
  339. (*                                                                      *)
  340. (*        Fsize := Get_File_Size( Fname      : AnyStr;                  *)
  341. (*                                Var OpenOK : Boolean ) : Real;        *)
  342. (*                                                                      *)
  343. (*           Fname  --- name of file to find size of                    *)
  344. (*           OpenOK --- set TRUE if file opened successfully            *)
  345. (*           Fsize  --- file size in bytes                              *)
  346. (*                                                                      *)
  347. (*     Calls:                                                           *)
  348. (*                                                                      *)
  349. (*        Reset                                                         *)
  350. (*        IoResult                                                      *)
  351. (*        Assign                                                        *)
  352. (*        LongFileSize                                                  *)
  353. (*        Close                                                         *)
  354. (*                                                                      *)
  355. (*     Remarks:                                                         *)
  356. (*                                                                      *)
  357. (*        The file must not already be opened before calling this       *)
  358. (*        routine.                                                      *)
  359. (*                                                                      *)
  360.  
  361. Var
  362.    F : File Of Byte;
  363.  
  364. Begin (* Get_File_Size *)
  365.  
  366.    Get_File_Size := 0.0;
  367.  
  368.    Assign( F , Fname );
  369.    (*$I- *)
  370.    Reset( F );
  371.    (*$I+ *)
  372.  
  373.    If IoResult = 0 Then
  374.       Begin
  375.          Get_File_Size := LongFileSize( F );
  376.          Close( F );
  377.          OpenOK := TRUE;
  378.       End
  379.    Else
  380.       OpenOK := FALSE;
  381.  
  382. End   (* Get_File_Size *);
  383.  
  384. (*----------------------------------------------------------------------*)
  385. (*           View_Prompt --- prompt for end-of-screen                   *)
  386. (*----------------------------------------------------------------------*)
  387.  
  388. Procedure View_Prompt( Var View_Done : Boolean; Var View_Count : Integer );
  389.  
  390. (*                                                                      *)
  391. (*     Procedure:  View_Prompt                                          *)
  392. (*                                                                      *)
  393. (*     Purpose:    Issues end-of-screen prompt for view routines        *)
  394. (*                                                                      *)
  395. (*     Calling Sequence:                                                *)
  396. (*                                                                      *)
  397. (*        View_Prompt( Var View_Done  : Boolean;                        *)
  398. (*                     Var View_Count : Integer );                      *)
  399. (*                                                                      *)
  400. (*           View_Done  --- TRUE if Stop option selected here           *)
  401. (*           View_Count --- Count of lines per panel.  May be changed   *)
  402. (*                          here if C option selected.                  *)
  403. (*                                                                      *)
  404. (*     Calls:   RvsVideoOn                                              *)
  405. (*              RvsVideoOff                                             *)
  406. (*                                                                      *)
  407. (*     Called by:                                                       *)
  408. (*                                                                      *)
  409. (*        View_A_File                                                   *)
  410. (*        View_A_Directory                                              *)
  411. (*                                                                      *)
  412.  
  413. Begin (* View_Prompt *)
  414.  
  415.    View_Count := 0;
  416.    View_Y     := WhereY;
  417.  
  418.    Repeat
  419.  
  420.       GoToXY( 1 , View_Y );
  421.       ClrEol;
  422.  
  423.       RvsVideoOn( Menu_Text_Color , BackGround_Color );
  424.  
  425.       Write('Enter CR to continue, S to stop, ',
  426.             'C to continue non-stop: ');
  427.  
  428.       RvsVideoOff( Menu_Text_Color , BackGround_Color );
  429.  
  430.       While ( NOT KeyPressed ) Do ;
  431.  
  432.       Read( Kbd, View_Char );
  433.  
  434.       If LENGTH( View_Char ) > 0  Then
  435.          If View_Char[1] <> CHR(ESC) Then
  436.             Begin
  437.                Write( View_Char[1] );
  438.                View_Char := UPCASE( View_Char[1] );
  439.             End
  440.          Else
  441.             Begin
  442.                Read( Kbd , View_Char );
  443.                View_Char := UPCASE( View_Char[1] );
  444.             End
  445.       Else
  446.          View_Char := ' ';
  447.  
  448.    Until( View_Char[1] IN ['S', 'C', ' '] );
  449.  
  450.    Case View_Char[1] Of
  451.       'C':  View_Count := -MaxInt;
  452.       'S':  View_Done  := TRUE;
  453.       Else
  454.             ;
  455.    End (* Case *);
  456.  
  457.    GoToXY( 1 , View_Y );
  458.    ClrEol;
  459.    GoToXY( 1 , View_Y );
  460.  
  461. End  (* View_Prompt *);
  462.  
  463. (*----------------------------------------------------------------------*)
  464. (*           View_A_File --- List ascii file                            *)
  465. (*----------------------------------------------------------------------*)
  466.  
  467. Procedure View_A_File;
  468.  
  469. (*                                                                      *)
  470. (*     Procedure:  View_A_File                                          *)
  471. (*                                                                      *)
  472. (*     Purpose:    Lists selected ascii file                            *)
  473. (*                                                                      *)
  474. (*     Calling Sequence:                                                *)
  475. (*                                                                      *)
  476. (*        View_A_File;                                                  *)
  477. (*                                                                      *)
  478. (*     Calls:   View_Prompt                                             *)
  479. (*              Save_Screen                                             *)
  480. (*              Restore_Screen                                          *)
  481. (*              Draw_Menu_Frame                                         *)
  482. (*              Reset_Global_Colors                                     *)
  483. (*                                                                      *)
  484. (*     Remarks:                                                         *)
  485. (*                                                                      *)
  486. (*        This routine will list non-ascii files, but they will be      *)
  487. (*        meaningless.                                                  *)
  488. (*                                                                      *)
  489.  
  490. Var
  491.    View_File_Name : String[15];
  492.    ViewFile       : Text;
  493.    View_File_Open : Boolean;
  494.    View_File_Size : Real;
  495.  
  496. Begin (* View_A_File *)
  497.                                    (*  Draw view menu *)
  498.  
  499.    Save_Screen( Saved_Screen );
  500.    Draw_Menu_Frame( 5, 4, 75, 25, Menu_Frame_Color,
  501.                     Menu_Text_Color, 'View A File' );
  502.  
  503.                                    (* Get name of file to list *)
  504.    Writeln;
  505.    Write('Enter name of file to list: ');
  506.    Readln( View_File_Name );
  507.  
  508.    View_File_Open := FALSE;
  509.  
  510.                                    (* Ensure file exists ... *)
  511.    If LENGTH( View_File_Name ) > 0 Then
  512.       Begin  (* View_File_Name > 0 *)
  513.  
  514.          View_File_Size := Get_File_Size( View_File_Name , View_File_Open );
  515.  
  516.  
  517.          If ( NOT View_File_Open ) Then
  518.             Begin (* IOResult <> 0 *)
  519.                TextColor( Menu_Text_Color + Blink );
  520.                Writeln('>>> Can''t open file ',View_File_Name,' for viewing.');
  521.                Delay( 2000 );
  522.                TextColor( Menu_Text_Color );
  523.             End   (* IOResult <> 0 *)
  524.  
  525.                                    (* ... and file is not empty *)
  526.  
  527.         Else If ( View_File_Size <= 0  ) Then
  528.             Begin  (* File is empty *)
  529.                TextColor( Menu_Text_Color + Blink );
  530.                Writeln('>>> File ',View_File_Name,' is empty.');
  531.                Delay( 2000 );
  532.                TextColor( Menu_Text_Color );
  533.             End    (* File is empty *)
  534.  
  535.         Else                       (* Write header line         *)
  536.             Begin  (* List the File *)
  537.  
  538.                Assign( ViewFile, View_File_Name );
  539.                Reset( ViewFile );
  540.  
  541.                ClrScr;
  542.  
  543.                RvsVideoOn( Menu_Text_Color , BackGround_Color );
  544.  
  545.                Writeln('LISTING OF FILE: ',View_File_Name,
  546.                        '        SIZE: ', View_File_Size:8:0, ' BYTES.');
  547.  
  548.                RvsVideoOff( Menu_Text_Color , BackGround_Color );
  549.  
  550.                                    (* Reset window so header doesn't vanish *)
  551.                Window( 7, 6, 74, 24 );
  552.                GoToXY( 1 , WhereY );
  553.  
  554.                                    (* List the file             *)
  555.  
  556.                View_Count := 0;
  557.                View_Done  := FALSE;
  558.  
  559.                Repeat
  560.                                    (* Read and write line from file *)
  561.                   Readln ( ViewFile , View_Line );
  562.                   If Length( View_Line ) > 65 Then View_Line[0] := CHR( 65 );
  563.                   Writeln( View_Line );
  564.  
  565.                                    (* Increment count of lines displayed *)
  566.                   View_Count := View_Count + 1;
  567.  
  568.                                    (* Prompt if end of screen *)
  569.                   If View_Count > 17 Then
  570.                      View_Prompt( View_Done , View_Count );
  571.  
  572.                Until EOF( ViewFile ) OR View_Done;
  573.  
  574.                RvsVideoOn( Menu_Text_Color , BackGround_Color );
  575.                Write('Viewing of file complete. ',
  576.                      'Hit any key to continue.');
  577.                RvsVideoOff( Menu_Text_Color , BackGround_Color );
  578.                While ( Not KeyPressed ) Do ;
  579.                Read( Kbd , View_Char[1] );
  580.  
  581.             End  (* List the file *);
  582.  
  583.       End  (* View_File_Name > 0 *);
  584.  
  585.    If View_File_Open Then Close( ViewFile );
  586.  
  587.    Restore_Screen( Saved_Screen );
  588.    Reset_Global_Colors;
  589.  
  590. End   (* View_A_File *);
  591.  
  592. (*----------------------------------------------------------------------*)
  593. (*      View_Directory --- List files in current directory              *)
  594. (*----------------------------------------------------------------------*)
  595.  
  596. Procedure View_Directory;
  597.  
  598. (*                                                                      *)
  599. (*     Procedure:  View_Directory                                       *)
  600. (*                                                                      *)
  601. (*     Purpose:    Lists files in current MSDOS directory               *)
  602. (*                                                                      *)
  603. (*     Calling Sequence:                                                *)
  604. (*                                                                      *)
  605. (*        View_Directory;                                               *)
  606. (*                                                                      *)
  607. (*     Calls:   View_Prompt                                             *)
  608. (*              Save_Screen                                             *)
  609. (*              Restore_Screen                                          *)
  610. (*              Draw_Menu_Frame                                         *)
  611. (*              Reset_Global_Colors                                     *)
  612. (*              Dir_Get_Default_Drive                                   *)
  613. (*              Dir_Get_Current_Path                                    *)
  614. (*              Dir_Find_First_File                                     *)
  615. (*              Dir_Find_Next_File                                      *)
  616. (*              Dir_Convert_Time                                        *)
  617. (*              Dir_Convert_Date                                        *)
  618. (*                                                                      *)
  619.  
  620. Var
  621.    View_Directory_Name : AnyStr;
  622.    Drive_Ch            : Char;
  623.    Iok                 : Integer;
  624.    File_Entry          : Directory_Record;
  625.    S_File_Name         : String[14];
  626.    S_File_Time         : String[8];
  627.    S_File_Date         : String[8];
  628.    S_File_Size         : Real;
  629.    Fs1                 : Real;
  630.    Fs2                 : Real;
  631.    I                   : Integer;
  632.  
  633. Begin (* View_Directory *)
  634.                                    (*  Draw view menu *)
  635.  
  636.    Save_Screen( Saved_Screen );
  637.    Draw_Menu_Frame( 5, 4, 75, 25, Menu_Frame_Color,
  638.                     Menu_Text_Color, 'View Current Directory' );
  639.  
  640.    ClrScr;
  641.  
  642.    RvsVideoOn( Menu_Text_Color , BackGround_Color );
  643.  
  644.    Drive_Ch := Dir_Get_Default_Drive;
  645.  
  646.    Iok := Dir_Get_Current_Path( Drive_Ch , View_Directory_Name );
  647.  
  648.    Writeln('LISTING OF DIRECTORY: ',Drive_Ch + ':\' + View_Directory_Name );
  649.  
  650.    RvsVideoOff( Menu_Text_Color , BackGround_Color );
  651.  
  652.                                    (* Reset window so header doesn't vanish *)
  653.    Window( 7, 6, 74, 24 );
  654.    GoToXY( 1 , WhereY );
  655.  
  656.                                    (* List the directory contents   *)
  657.  
  658.    View_Count := 0;
  659.    View_Done  := ( Dir_Find_First_File( '*.*', File_Entry ) <> 0 );
  660.  
  661.    Repeat
  662.                                    (* Display Next Directory Entry       *)
  663.  
  664.       S_File_Name := '';
  665.       I           := 1;
  666.  
  667.       While( ( I <= 14 ) AND ( File_Entry.File_Name[I] <> CHR(0) ) ) Do
  668.          Begin
  669.             S_File_Name := S_File_Name + File_Entry.File_Name[I];
  670.             I           := I + 1;
  671.          End;
  672.  
  673.       Dir_Convert_Time( File_Entry.File_Time , S_File_Time );
  674.       Dir_Convert_Date( File_Entry.File_Date , S_File_Date );
  675.  
  676.       Fs1 := File_Entry.File_Size[1];
  677.       Fs2 := File_Entry.File_Size[2];
  678.  
  679.       If Fs1 < 0 Then Fs1 := Fs1 + 65536.0;
  680.       If Fs2 < 0 Then Fs2 := Fs2 + 65536.0;
  681.  
  682.       S_File_Size := Fs2 * 65536.0 + Fs1;
  683.  
  684.       Writeln( S_File_Name:14, ' ', S_File_Size:8:0, ' ', S_File_Date, ' ',
  685.                S_File_Time );
  686.  
  687.                                    (* Increment count of lines displayed *)
  688.       View_Count := View_Count + 1;
  689.  
  690.                                    (* Prompt if end of screen *)
  691.       If View_Count > 17 Then
  692.          View_Prompt( View_Done , View_Count );
  693.  
  694.       If NOT View_Done Then
  695.          View_Done := ( Dir_Find_Next_File( File_Entry ) <> 0 );
  696.  
  697.    Until View_Done;
  698.  
  699.                                    (* Issue final end-of-directory prompt *)
  700.    RvsVideoOn( Menu_Text_Color , BackGround_Color );
  701.  
  702.    Write('Viewing of directory complete. ',
  703.          'Hit any key to continue.');
  704.  
  705.    RvsVideoOff( Menu_Text_Color , BackGround_Color );
  706.  
  707.    While ( NOT KeyPressed ) Do ;
  708.  
  709.    Read( Kbd , View_Char );
  710.                                    (* Restore previous screen *)
  711.    Restore_Screen( Saved_Screen );
  712.    Reset_Global_Colors;
  713.  
  714. End   (* View_Directory *);
  715.  
  716.  
  717.  
  718. (*----------------------------------------------------------------------*)
  719. (*      Log_Drive_Change --- Change current logged drive                *)
  720. (*----------------------------------------------------------------------*)
  721.  
  722. Procedure Log_Drive_Change;
  723.  
  724. (*                                                                      *)
  725. (*     Procedure:  Log_Drive_Change                                     *)
  726. (*                                                                      *)
  727. (*     Purpose:    Change current logged drive                          *)
  728. (*                                                                      *)
  729. (*     Calling Sequence:                                                *)
  730. (*                                                                      *)
  731. (*        Log_Drive_Change                                              *)
  732. (*                                                                      *)
  733. (*     Calls:   Dir_Get_Default_Drive                                   *)
  734. (*              Dir_Set_Default_Drive                                   *)
  735. (*              Save_Screen                                             *)
  736. (*              Restore_Screen                                          *)
  737. (*              Draw_Menu_Frame                                         *)
  738. (*              Reset_Global_Colors                                     *)
  739. (*                                                                      *)
  740. (*                                                                      *)
  741.  
  742. Var
  743.    Drive_Ch    : String[1];
  744.    Drive_No    : Integer;
  745.    Drive_Count : Integer;
  746.  
  747. Begin (* Log_Drive_Change *);
  748.  
  749.                                    (*  Draw log change menu *)
  750.  
  751.    Save_Screen( Saved_Screen );
  752.    Draw_Menu_Frame( 5, 10, 75, 15, Menu_Frame_Color,
  753.                     Menu_Text_Color, 'Change Current Logged Drive' );
  754.  
  755.    ClrScr;
  756.  
  757.    GoToXY( 1 , 1 );
  758.    Drive_Ch[1] := Dir_Get_Default_Drive;
  759.  
  760.    Writeln('Current logged drive is ',Drive_Ch[1] );
  761.  
  762.    GoToXY( 1 , 2 );
  763.  
  764.    Write('Enter letter for new logged drive: ');
  765.  
  766.    Read( Kbd , Drive_Ch );
  767.    Write( Drive_Ch );
  768.  
  769.    If LENGTH( Drive_Ch ) = 0 Then
  770.       Begin
  771.          Writeln;
  772.          Writeln('*** Logged drive remains unchanged.')
  773.       End
  774.    Else
  775.       Begin
  776.                                 (* Figure no. of drives in system *)
  777.          Drive_Count := Dir_Count_Drives;
  778.  
  779.                                 (* Drive no. for entered letter   *)
  780.          Drive_No    := ORD( UpCase( Drive_Ch ) ) - ORD( 'A' );
  781.  
  782.                                 (* Check if drive legitimate      *)
  783.  
  784.          If ( Drive_No < 0 ) OR ( Drive_No > Drive_Count ) Then
  785.             Writeln('*** Invalid drive, logged drive unchanged.')
  786.          Else
  787.             Begin
  788.                                 (* Change default drive *)
  789.                Dir_Set_Default_Drive( Drive_Ch );
  790.  
  791.                Writeln;
  792.                Writeln('*** Logged drive changed to ',Drive_Ch );
  793.  
  794.             End;
  795.  
  796.       End;
  797.  
  798.    Delay( 2000 );
  799.  
  800.                                    (* Restore previous screen *)
  801.    Restore_Screen( Saved_Screen );
  802.    Reset_Global_Colors;
  803.  
  804. End   (* Log_Drive_Change *);
  805.  
  806. (*----------------------------------------------------------------------*)
  807. (*       Change_Subdirectory --- Change current disk subdirectory       *)
  808. (*----------------------------------------------------------------------*)
  809.  
  810. Procedure Change_Subdirectory;
  811.  
  812. (*                                                                      *)
  813. (*     Procedure:  Change_Subdirectory                                  *)
  814. (*                                                                      *)
  815. (*     Purpose:    Change current subdirectory                          *)
  816. (*                                                                      *)
  817. (*     Calling Sequence:                                                *)
  818. (*                                                                      *)
  819. (*        Change_Subdirectory;                                          *)
  820. (*                                                                      *)
  821. (*     Calls:   Dir_Get_Default_Drive                                   *)
  822. (*              Dir_Set_Current_Path                                    *)
  823. (*              Dir_Get_Current_Path                                    *)
  824. (*              Save_Screen                                             *)
  825. (*              Restore_Screen                                          *)
  826. (*              Draw_Menu_Frame                                         *)
  827. (*              Reset_Global_Colors                                     *)
  828. (*                                                                      *)
  829. (*                                                                      *)
  830.  
  831. Var
  832.    Path_Name : AnyStr;
  833.    Iok       : Integer;
  834.    Drive_Ch  : Char;
  835.  
  836. Begin (* Change_Subdirectory *)
  837.                                    (*  Draw directory change menu *)
  838.  
  839.    Save_Screen( Saved_Screen );
  840.    Draw_Menu_Frame( 5, 10, 75, 15, Menu_Frame_Color,
  841.                     Menu_Text_Color, 'Change Current Directory' );
  842.  
  843.    ClrScr;
  844.  
  845.    GoToXY( 1 , 1 );
  846.  
  847.    Drive_Ch := Dir_Get_Default_Drive;
  848.  
  849.    Iok := Dir_Get_Current_Path( Drive_Ch , Path_Name );
  850.  
  851.    Writeln('Current directory is ', Drive_Ch + ':\' + Path_Name );
  852.  
  853.    Write('Enter name of new directory path: ');
  854.  
  855.    Read( Path_Name );
  856.    Writeln;
  857.  
  858.    If LENGTH( Path_Name ) = 0 Then
  859.       Writeln('*** Current directory remains unchanged.')
  860.    Else
  861.       Begin
  862.  
  863.          If Dir_Set_Current_Path( Path_Name ) = 0 Then
  864.             Writeln('*** Current directory changed to ',
  865.                     Drive_Ch + ':' + Path_Name )
  866.          Else
  867.             Writeln('*** Error found, directory not changed');
  868.       End;
  869.  
  870.    Delay( 2000 );
  871.  
  872.                                    (* Restore previous screen *)
  873.    Restore_Screen( Saved_Screen );
  874.    Reset_Global_Colors;
  875.  
  876. End   (* Change_Subdirectory *);
  877.  
  878. (*----------------------------------------------------------------------*)
  879. (*               Delete_A_File --- Delete a file                        *)
  880. (*----------------------------------------------------------------------*)
  881.  
  882. Procedure Delete_A_File;
  883.  
  884. (*                                                                      *)
  885. (*     Procedure:  Delete_A_File                                        *)
  886. (*                                                                      *)
  887. (*     Purpose:    Delete file in current subdirectory                  *)
  888. (*                                                                      *)
  889. (*     Calling Sequence:                                                *)
  890. (*                                                                      *)
  891. (*        Delete_A_File;                                                *)
  892. (*                                                                      *)
  893. (*     Calls:   Dir_Delete_File                                         *)
  894. (*              Save_Screen                                             *)
  895. (*              Restore_Screen                                          *)
  896. (*              Draw_Menu_Frame                                         *)
  897. (*              Reset_Global_Colors                                     *)
  898. (*                                                                      *)
  899.  
  900. Var
  901.    File_Name : AnyStr;
  902.  
  903. Begin (* Delete_A_File *)
  904.                                    (*  Draw delete file menu *)
  905.  
  906.    Save_Screen( Saved_Screen );
  907.    Draw_Menu_Frame( 5, 10, 75, 14, Menu_Frame_Color,
  908.                     Menu_Text_Color, 'Delete A File' );
  909.  
  910.    ClrScr;
  911.  
  912.    GoToXY( 1 , 1 );
  913.  
  914.    Write('Enter name of file to delete: ');
  915.  
  916.    Read( File_Name );
  917.    Writeln;
  918.  
  919.    If LENGTH( File_Name ) = 0 Then
  920.       Writeln('*** No file to delete.')
  921.    Else
  922.       If ( Dir_Delete_File( File_Name ) = 0 ) Then
  923.          Writeln('*** File deleted.')
  924.       Else
  925.          Writeln('*** File not found to delete or read-only');
  926.  
  927.    Delay( 2000 );
  928.  
  929.                                    (* Restore previous screen *)
  930.    Restore_Screen( Saved_Screen );
  931.    Reset_Global_Colors;
  932.  
  933. End   (* Delete_A_File *);
  934.  
  935. (*----------------------------------------------------------------------*)
  936. (*       Fast_Change_Params --- fast change of communications params.   *)
  937. (*----------------------------------------------------------------------*)
  938.  
  939. Procedure Fast_Change_Params;
  940.  
  941. (*                                                                      *)
  942. (*     Procedure:  Fast_Change_Params                                   *)
  943. (*                                                                      *)
  944. (*     Purpose:    Fast change of communications params                 *)
  945. (*                                                                      *)
  946. (*     Calling Sequence:                                                *)
  947. (*                                                                      *)
  948. (*        Fast_Change_Params;                                           *)
  949. (*                                                                      *)
  950. (*                                                                      *)
  951. (*      Remarks:                                                        *)
  952. (*                                                                      *)
  953. (*         This routine is useful is making a fast switch between       *)
  954. (*         the parameter values needed by XMODEM and those required     *)
  955. (*         by the remote host.                                          *)
  956. (*                                                                      *)
  957.  
  958. Const
  959.    Comm_Parities  : Array[ 1 .. 6 ] Of Char    = ('E','N','O','E','N','O');
  960.    Comm_Data_Bits : Array[ 1 .. 6 ] Of Integer = ( 7,  7,  7,  8,  8,  8 );
  961.  
  962. Var
  963.    Comm_Parms_Menu : Menu_Type;
  964.    Comm_Parms      : Integer;
  965.    OK_Setup        : Boolean;
  966.    I               : Integer;
  967.  
  968. Begin (* Fast_Change_Params *)
  969.  
  970.    Comm_Parms_Menu.Menu_Size    := 6;
  971.    Comm_Parms_Menu.Menu_Default := 5;
  972.    Comm_Parms_Menu.Menu_Row     := 11;
  973.    Comm_Parms_Menu.Menu_Column  := 30;
  974.    Comm_Parms_Menu.Menu_Tcolor  := Menu_Text_Color;
  975.    Comm_Parms_Menu.Menu_Bcolor  := BackGround_Color;
  976.    Comm_Parms_Menu.Menu_Fcolor  := Menu_Frame_Color;
  977.    Comm_Parms_Menu.Menu_Width   := 0;
  978.    Comm_Parms_Menu.Menu_Height  := 0;
  979.  
  980.    For I := 1 To 6 Do
  981.       With Comm_Parms_Menu.Menu_Entries[I] Do
  982.       Begin
  983.          Menu_Item_Row    := I;
  984.          Menu_Item_Column := 2;
  985.          Case I Of
  986.             1:  Menu_Item_Text := 'Even parity, 7 bits, 1 stop';
  987.             2:  Menu_Item_Text := 'No parity,   7 bits, 1 stop';
  988.             3:  Menu_Item_Text := 'Odd parity,  7 bits, 1 stop';
  989.             4:  Menu_Item_Text := 'Even parity, 8 bits, 1 stop';
  990.             5:  Menu_Item_Text := 'No parity,   8 bits, 1 stop (Xmodem)';
  991.             6:  Menu_Item_Text := 'Odd parity,  8 bits, 1 stop';
  992.          End (* Case *);
  993.       End;
  994.  
  995.    Comm_Parms_Menu.Menu_Title := 'Choose new communications parameters: ';
  996.  
  997.    Menu_Display_Choices( Comm_Parms_Menu );
  998.    Comm_Parms := Menu_Get_Choice( Comm_Parms_Menu , Erase_Menu );
  999.  
  1000.    Parity    := Comm_Parities[ Comm_Parms ];
  1001.    Data_Bits := Comm_Data_Bits[ Comm_Parms ];
  1002.  
  1003.    OK_Setup  := Async_Open( Comm_Port, Baud_Rate, Parity, Data_Bits, 1 );
  1004.  
  1005. End   (* Fast_Change_Params *);
  1006.  
  1007. (*----------------------------------------------------------------------*)
  1008. (*           Process_Command --- Process PibTerm  command               *)
  1009. (*----------------------------------------------------------------------*)
  1010.  
  1011. Procedure Process_Command( Var Done: Boolean;
  1012.                            Var Ch  : Char;
  1013.                            Use_Ch  : Boolean );
  1014.  
  1015. (*                                                                      *)
  1016. (*     Procedure:  Process_Command                                      *)
  1017. (*                                                                      *)
  1018. (*     Purpose:    Process PibTerm Command escape sequence              *)
  1019. (*                                                                      *)
  1020. (*     Calling Sequence:                                                *)
  1021. (*                                                                      *)
  1022. (*        Process_Command( Var Done : Boolean; Var Ch: Char;            *)
  1023. (*                         Use_Ch: Boolean );                           *)
  1024. (*                                                                      *)
  1025. (*           Done   --- set TRUE if termination command (Alt-X) found   *)
  1026. (*           Ch     --- character following ESC                         *)
  1027. (*           Use_Ch --- TRUE if Ch on entry is char following ESC,      *)
  1028. (*                      FALSE if Ch to be read here.                    *)
  1029. (*                                                                      *)
  1030. (*      Calls:   Async_Send_String                                      *)
  1031. (*               Dial_A_Number                                          *)
  1032. (*               Async_Send_Break                                       *)
  1033. (*               Async_Carrier_Detect                                   *)
  1034. (*               Display_Commands                                       *)
  1035. (*               Delay                                                  *)
  1036. (*               UpLoad                                                 *)
  1037. (*               DownLoad                                               *)
  1038. (*               Get_File_Transfer_Protocol                             *)
  1039. (*               Save_Screen                                            *)
  1040. (*               Restore_Screen                                         *)
  1041. (*               Draw_Menu_Frame                                        *)
  1042. (*               Fast_Change_Params                                     *)
  1043. (*               Delete_A_File                                          *)
  1044. (*                                                                      *)
  1045. (*      Remarks:                                                        *)
  1046. (*                                                                      *)
  1047. (*         All PibTerm commands are implemented as escape sequences,    *)
  1048. (*         very much like PC-TALK or QMODEM.  The available commands    *)
  1049. (*         are:                                                         *)
  1050. (*                                                                      *)
  1051. (*            Alt-B:  Send Break                                        *)
  1052. (*            Alt-C:  Clear Screen                                      *)
  1053. (*            Alt-D:  Dial a number (Hayes-like modems only)            *)
  1054. (*            Alt-E:  Turn local echo ON/OFF                            *)
  1055. (*            Alt-F:  Fast change of communications params              *)
  1056. (*            Alt-H:  Hang up the phone (Hayes-like modems only)        *)
  1057. (*            Alt-L:  Log Drive Change                                  *)
  1058. (*            Alt-O:  Change Subdirectory                               *)
  1059. (*            Alt-P:  Set communications parameters                     *)
  1060. (*            Alt-Q:  Redial last number dialed                         *)
  1061. (*            Alt-S:  Toggle Silent Mode                                *)
  1062. (*            Alt-V:  View a file                                       *)
  1063. (*            Alt-W:  View disk directory                               *)
  1064. (*            Alt-X:  Leave Program                                     *)
  1065. (*            Alt-Y:  Delete a file                                     *)
  1066. (*            Alt-Z:  Produce this command list                         *)
  1067. (*            PgUp:   Upload a file                                     *)
  1068. (*            PgDn:   Download a file                                   *)
  1069. (*                                                                      *)
  1070.  
  1071. Var
  1072.    YesNo : Char;
  1073.    Flag  : Boolean;
  1074.  
  1075. Begin (* Process_Command *)
  1076.  
  1077.                    (* Pick up character following escape *)
  1078.    If NOT Use_Ch Then Read( Kbd , Ch );
  1079.  
  1080.                    (* Interpret it                       *)
  1081.  
  1082.    Case ORD( Ch ) Of
  1083.  
  1084.       16: Dial_A_Number( TRUE );
  1085.  
  1086.       17: View_Directory;
  1087.  
  1088.       18: Begin (* Turn Local Echo On/Off *)
  1089.  
  1090.              Local_Echo := NOT Local_Echo;
  1091.  
  1092.              Save_Screen( Saved_Screen );
  1093.              Draw_Menu_Frame( 10, 10, 55, 15, Menu_Frame_Color,
  1094.                          Menu_Text_Color, '' );
  1095.  
  1096.              Case Local_Echo OF
  1097.  
  1098.                 TRUE:  Begin
  1099.                           Writeln;
  1100.                           Writeln('*** Local echo now ON');
  1101.                        End;
  1102.  
  1103.                 FALSE: Begin
  1104.                           Writeln;
  1105.                           Writeln('*** Local echo now OFF');
  1106.                        End;
  1107.  
  1108.              End (* Case *);
  1109.  
  1110.              Delay( 2000 );
  1111.  
  1112.              Restore_Screen( Saved_Screen );
  1113.  
  1114.              Reset_Global_Colors;
  1115.  
  1116.           End   (* Turn Local Echo On/Off *);
  1117.  
  1118.       21: Delete_A_File;
  1119.  
  1120.       24: Change_Subdirectory;
  1121.  
  1122.       25: Flag := Set_Params( FALSE );
  1123.  
  1124.       31: Begin (* Turn Silent Mode On/Off *)
  1125.  
  1126.              Silent_Mode := NOT Silent_Mode;
  1127.  
  1128.              Save_Screen( Saved_Screen );
  1129.              Draw_Menu_Frame( 10, 10, 55, 15, Menu_Frame_Color,
  1130.                          Menu_Text_Color, '' );
  1131.  
  1132.              Case Silent_Mode OF
  1133.  
  1134.                 TRUE:  Begin
  1135.                           Writeln;
  1136.                           Writeln('*** Silent Mode now ON');
  1137.                        End;
  1138.  
  1139.                 FALSE: Begin
  1140.                           Writeln;
  1141.                           Writeln('*** Silent Mode now OFF');
  1142.                        End;
  1143.  
  1144.              End (* Case *);
  1145.  
  1146.              Delay( 2000 );
  1147.  
  1148.              Restore_Screen( Saved_Screen );
  1149.  
  1150.              Reset_Global_Colors;
  1151.  
  1152.           End   (* Turn Silent Mode On/Off *);
  1153.  
  1154.       32: Dial_A_Number( FALSE );
  1155.  
  1156.       38: Log_Drive_Change;
  1157.  
  1158.       33: Fast_Change_Params;
  1159.  
  1160.       46: ClrScr;
  1161.  
  1162.       48: Begin (* Send_Break *)
  1163.              Async_Send_Break;
  1164.           End;
  1165.  
  1166.       44: Display_Commands( FALSE );
  1167.  
  1168.       45: Begin (* Quit *)
  1169.  
  1170.              Save_Screen( Saved_Screen );
  1171.  
  1172.              Draw_Menu_Frame( 10, 10, 61, 13, Menu_Frame_Color,
  1173.                               Menu_Text_Color, '' );
  1174.  
  1175.              Writeln;
  1176.              Write('Are you sure you want to quit (Y/N)? ');
  1177.  
  1178.              Read( Kbd , YesNo );
  1179.              Write( YesNo );
  1180.  
  1181.              Done := ( YesNo IN ['Y','y'] );
  1182.  
  1183.              Restore_Screen( Saved_Screen );
  1184.  
  1185.              Reset_Global_Colors;
  1186.  
  1187.           End;
  1188.  
  1189.       35: Begin (* Hang-up Phone *)
  1190.  
  1191.              Save_Screen( Saved_Screen );
  1192.  
  1193.              Draw_Menu_Frame( 10, 10, 50, 15, Menu_Frame_Color,
  1194.                               Menu_Text_Color, '' );
  1195.  
  1196.              Writeln;
  1197.              Writeln('*** Hanging up the phone ***');
  1198.  
  1199.              Delay( Two_Seconds );
  1200.  
  1201.              Async_Send_String('+++');
  1202.  
  1203.              Delay( Two_Seconds );
  1204.  
  1205.              Async_Send_String( 'ATH0' + CHR( CR ) );
  1206.  
  1207.              Delay( Two_Seconds );
  1208.  
  1209.              If Async_Carrier_Detect Then
  1210.                 Writeln('*** Phone not hung up, try again ***')
  1211.              Else
  1212.                 Writeln('*** Phone hung up ***');
  1213.  
  1214.              Delay( 3000 );
  1215.  
  1216.              Restore_Screen( Saved_Screen );
  1217.  
  1218.              Reset_Global_Colors;
  1219.  
  1220.           End   (* Hang-up Phone *);
  1221.  
  1222.       47: View_A_File;
  1223.  
  1224.       73: Begin (* Upload a file *)
  1225.              UpLoad( Get_File_Transfer_Protocol('sending file') );
  1226.           End   (* Upload a file *);
  1227.  
  1228.       81: Begin (* Download a file *)
  1229.              DownLoad( Get_File_Transfer_Protocol('receiving file') );
  1230.           End;
  1231.  
  1232.       Else
  1233.             ;
  1234.    End (* Case *);
  1235.  
  1236. End   (* Process_Command *);
  1237.  
  1238. (*----------------------------------------------------------------------*)
  1239. (*           Display_Character --- show character received from port    *)
  1240. (*----------------------------------------------------------------------*)
  1241.  
  1242. Procedure Display_Character( Ch : Char );
  1243.  
  1244. (*                                                                      *)
  1245. (*     Procedure:  Display_Character                                    *)
  1246. (*                                                                      *)
  1247. (*     Purpose:    Displays character received from comm. port          *)
  1248. (*                                                                      *)
  1249. (*     Calling Sequence:                                                *)
  1250. (*                                                                      *)
  1251. (*        Display_Character( Ch : Char );                               *)
  1252. (*                                                                      *)
  1253. (*           Ch --- Character received from Comm. port.                 *)
  1254. (*                                                                      *)
  1255. (*      Calls:   Async_Receive                                          *)
  1256. (*                                                                      *)
  1257. (*      Remarks:                                                        *)
  1258. (*                                                                      *)
  1259. (*         This routine exists to strip out certain characters which    *)
  1260. (*         should not be displayed, and also to implement the XON/XOFF  *)
  1261. (*         protocol in a simple-minded manner.                          *)
  1262. (*                                                                      *)
  1263.  
  1264. Begin (* Display_Character *)
  1265.  
  1266.    Case ORD( Ch ) Of
  1267.  
  1268.       NUL  :    ;       (* Strip Nulls              *)
  1269.       DEL  :    ;       (* Strip Deletes            *)
  1270.       XON  :    ;       (* Strip unattached XONs    *)
  1271.  
  1272.       XOFF :    Begin (* Handle XOFF *)
  1273.  
  1274.                                (* Wait for XON *)
  1275.                    Repeat
  1276.                       Delay( Tenth_of_a_second );
  1277.                       While( NOT Async_Receive( Ch ) ) Do;
  1278.                    Until( Ch = CHR( XON ) );
  1279.  
  1280.                 End   (* Handle XOFF *);
  1281.  
  1282.       BELL :    If Not Silent_Mode Then
  1283.                    Write( Ch );
  1284.  
  1285.       Else
  1286.             Write( Ch );
  1287.  
  1288.    End (* Case *);
  1289.  
  1290. End   (* Display_Character *);
  1291.  
  1292. (*$IPIBSCROL.PAS *)
  1293. (*$IPIBVT52.PAS  *)
  1294. (*$IPIBDUMBT.PAS *)
  1295.  
  1296. (* ------------------------------------------------------------------------ *)
  1297. (*                  PibTerm  --- Main Program                               *)
  1298. (* ------------------------------------------------------------------------ *)
  1299.  
  1300. Begin (* PibTerm  *)
  1301.                                    (* Select color/mono screen *)
  1302.    Get_Screen_Address( Actual_Screen );
  1303.  
  1304.                                    (* Establish colors         *)
  1305.    Set_Global_Colors( Yellow, Black );
  1306.  
  1307.                                    (* Silent mode OFF to start *)
  1308.    Silent_Mode := FALSE;
  1309.                                    (* Local echo starts at OFF *)
  1310.    Local_Echo := FALSE;
  1311.                                    (* Phone number to dial     *)
  1312.    Phone_Number := '';
  1313.                                    (* Establish Communications *)
  1314.  
  1315.    If NOT Set_Params( True ) Then
  1316.       Begin
  1317.          Writeln('*** Sorry, can''t initialize communications.');
  1318.          Writeln('*** Program stops.');
  1319.          Halt;
  1320.       End;
  1321.  
  1322.                                    (* Give Instructions        *)
  1323.    Display_Commands( TRUE );
  1324.  
  1325.                                    (* Begin Terminal Emulation *)
  1326.    Case Terminal_To_Emulate Of
  1327.       VT52: Emulate_VT52;
  1328.       Dumb: Emulate_Dumb_Terminal;
  1329.    End (* Case *);
  1330.  
  1331.                                    (* End Terminal Emulation   *)
  1332.    Async_Close;
  1333.                                    (* Clear screen             *)
  1334.    ClrScr;
  1335.  
  1336. End   (* PibTerm  *).
  1337.