home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / GETCAPTU.MOD < prev    next >
Text File  |  1988-03-07  |  8KB  |  198 lines

  1. (*----------------------------------------------------------------------*)
  2. (*          Get_Capture_File -- Get session capture file name           *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Get_Capture_File( Capture_FName : AnyStr;
  6.                             Capture_Type  : AnyStr   );
  7.  
  8. (*----------------------------------------------------------------------*)
  9. (*                                                                      *)
  10. (*     Procedure:  Get_Capture_File                                     *)
  11. (*                                                                      *)
  12. (*     Purpose:    Opens capture file                                   *)
  13. (*                                                                      *)
  14. (*     Calling Sequence:                                                *)
  15. (*                                                                      *)
  16. (*        Get_Capture_File( Capture_FName : AnyStr;                     *)
  17. (*                          Capture_Type  : AnyStr );                   *)
  18. (*                                                                      *)
  19. (*           Capture_FName --- name of capture file; prompted for       *)
  20. (*                             if null.                                 *)
  21. (*           Capture_Type  --- type of capture to perform.              *)
  22. (*                             E = edited, U = unedited.                *)
  23. (*                                                                      *)
  24. (*     Calls:                                                           *)
  25. (*                                                                      *)
  26. (*        Open_For_Append                                               *)
  27. (*        YesNo                                                         *)
  28. (*        Save_Screen                                                   *)
  29. (*        Draw_Menu_Frame                                               *)
  30. (*        Restore_Screen                                                *)
  31. (*        Reset_Global_Colors                                           *)
  32. (*        Add_Path                                                      *)
  33. (*                                                                      *)
  34. (*----------------------------------------------------------------------*)
  35.  
  36. VAR
  37.    OK_File           : BOOLEAN;
  38.    Open_OK           : BOOLEAN;
  39.    File_Exists       : BOOLEAN;
  40.    Name_Given        : BOOLEAN;
  41.    Ierr              : INTEGER;
  42.    CurDir            : AnyStr;
  43.  
  44. BEGIN (* Get_Capture_File *)
  45.  
  46.    Draw_Titled_Box( Saved_Screen, 10, 10, 75, 17, 'Capture session' );
  47.  
  48.                                    (* If capture mode ON, close current  *)
  49.                                    (* capture file and turn capture mode *)
  50.                                    (* OFF.                               *)
  51.    IF Capture_On THEN
  52.       BEGIN
  53.             (*!I-*)
  54.          CLOSE( Capture_File );
  55.             (*!I+*)
  56.          Capture_On := FALSE;
  57.          TextColor( Menu_Text_Color_2 );
  58.          WRITELN;
  59.          WRITELN('*** Capturing of session to ', Capture_File_Name,
  60.                  ' terminated.');
  61.          TextColor( Menu_Text_Color );
  62.          Window_Delay;
  63.       END
  64.    ELSE                            (* If capture mode OFF, then get name *)
  65.                                    (* of file to capture to, and turn on *)
  66.                                    (* capture mode.                      *)
  67.  
  68.       BEGIN  (* Capture mode was Off *)
  69.  
  70.          Capture_File_Name := Capture_FName;
  71.  
  72.          OK_File     := FALSE;
  73.          Name_Given  := LENGTH( Capture_File_Name ) > 0;
  74.  
  75.          GetDir( 0 , CurDir );
  76.  
  77.          REPEAT
  78.  
  79.             Clear_Window;
  80.  
  81.             TextColor( Menu_Text_Color_2 );
  82.             WRITE('File name to capture session to ? ');
  83.             TextColor( Menu_Text_Color );
  84.  
  85.             IF ( NOT Name_Given ) THEN
  86.                BEGIN
  87.                   Capture_File_Name := '';
  88.                   Read_Edited_String( Capture_File_Name );
  89.                   WRITELN;
  90.                   IF Capture_File_Name = CHR( ESC ) THEN
  91.                      Capture_File_Name := '';
  92.                END
  93.             ELSE
  94.                WRITELN( Capture_File_Name );
  95.  
  96.             Window_Delay;
  97.  
  98.             IF ( LENGTH( Capture_File_Name ) > 0 ) THEN
  99.                BEGIN
  100.  
  101.                   ASSIGN( Capture_File , Capture_File_Name );
  102.                      (*!I-*)
  103.                   RESET( Capture_File );
  104.                      (*!I+*)
  105.  
  106.                   IF Int24Result = 0 THEN
  107.                      BEGIN
  108.  
  109.                         IF ( NOT Name_Given ) THEN
  110.                            OK_File := YesNo('File ' + Capture_File_Name +
  111.                                             ' already exists, append to it (Y/N) ? ')
  112.                         ELSE
  113.                            OK_File := TRUE;
  114.  
  115.                         File_Exists := TRUE;
  116.  
  117.                            (*!I-*)
  118.                         CLOSE( Capture_File );
  119.                            (*!I+*)
  120.  
  121.                      END
  122.                   ELSE
  123.                      BEGIN
  124.                         OK_File     := TRUE;
  125.                         File_Exists := FALSE;
  126.                      END;
  127.  
  128.                END;
  129.  
  130.          UNTIL ( OK_File ) OR ( LENGTH( Capture_File_Name ) = 0 );
  131.  
  132.          IF LENGTH( Capture_File_Name ) > 0 THEN
  133.             BEGIN
  134.  
  135.                   (*!I-*)
  136.                IF File_Exists THEN
  137.                   Open_OK := Open_For_Append( Capture_File,
  138.                                               Capture_File_Name, Ierr )
  139.                ELSE
  140.                   BEGIN
  141.                         (*!I-*)
  142.                      ASSIGN ( Capture_File, Capture_File_Name );
  143.                      REWRITE( Capture_File );
  144.                         (*!I+*)
  145.                      Open_OK := ( Int24Result = 0 );
  146.                   END;
  147.  
  148.                IF ( NOT Open_OK ) THEN
  149.                   BEGIN
  150.                      TextColor( Menu_Text_Color_2 );
  151.                      WRITELN('Can''t open ',Capture_File_Name,' for output.');
  152.                      WRITELN('Capture will not be done.');
  153.                      TextColor( Menu_Text_Color );
  154.                   END
  155.                ELSE
  156.                   BEGIN
  157.  
  158.                      IF ( LENGTH( Capture_Type ) <= 0 ) THEN
  159.                         Capture_Type := ' ';
  160.  
  161.                      CASE UpCase(Capture_Type[1]) OF
  162.                         'U':  Exact_Capture := TRUE;
  163.                         'E':  Exact_Capture := FALSE;
  164.                         ELSE
  165.                            WRITELN;
  166.                            Exact_Capture := NOT YesNo('Perform edited capture? ');
  167.                            WRITELN;
  168.                      END (* CASE *);
  169.  
  170.                      TextColor( Menu_Text_Color_2 );
  171.  
  172.                      IF Exact_Capture THEN
  173.                         WRITE('Unedited')
  174.                      ELSE
  175.                         WRITE('Edited');
  176.  
  177.                      WRITE(' capture to ');
  178.  
  179.                      TextColor( Menu_Text_Color );
  180.  
  181.                      WRITE( Capture_File_Name );
  182.  
  183.                      Capture_On := TRUE;
  184.  
  185.                      Add_Path( Capture_File_Name , CurDir , Capture_File_Name );
  186.  
  187.                   END;
  188.  
  189.                Window_Delay;
  190.  
  191.             END (* Length( Capture_File_Name ) > 0 *);
  192.  
  193.       END  (* Capture mode was OFF *);
  194.  
  195.    Restore_Screen_And_Colors( Saved_Screen );
  196.  
  197. END   (* Get_Capture_File *);
  198.