home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s3.arc / PIBVIEW.MOD < prev    next >
Text File  |  1988-01-17  |  4KB  |  100 lines

  1. (*----------------------------------------------------------------------*)
  2. (*           View_A_File --- List ascii file                            *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE View_A_File( View_File_Name : AnyStr );
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  View_A_File                                          *)
  10. (*                                                                      *)
  11. (*     Purpose:    Lists selected ascii file                            *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        View_A_File;                                                  *)
  16. (*                                                                      *)
  17. (*     Calls:   View_Prompt                                             *)
  18. (*              Save_Screen                                             *)
  19. (*              Restore_Screen                                          *)
  20. (*              Draw_Menu_Frame                                         *)
  21. (*              Reset_Global_Colors                                     *)
  22. (*                                                                      *)
  23. (*     Remarks:                                                         *)
  24. (*                                                                      *)
  25. (*        This routine will list non-ascii files, but they will be      *)
  26. (*        meaningless.                                                  *)
  27. (*                                                                      *)
  28. (*----------------------------------------------------------------------*)
  29.  
  30. VAR
  31.    Save_Do_Status_Time : BOOLEAN;
  32.    View_File_Open      : BOOLEAN;
  33.    View_File_Size      : LONGINT;
  34.    Screen_Size         : INTEGER;
  35.    Name_Given          : BOOLEAN;
  36.  
  37. BEGIN (* View_A_File *)
  38.                                    (* No status time updates here *)
  39.  
  40.    Save_Do_Status_Time := Do_Status_Time;
  41.    Do_Status_Time      := FALSE;
  42.    Screen_Size         := Max_Screen_Line - 2;
  43.    Name_Given          := ( LENGTH( View_File_Name ) > 0 );
  44.  
  45.                                    (*  Draw view menu *)
  46.    Save_Screen( Saved_Screen );
  47.    Draw_Menu_Frame( 5, 10, 75, 16, Menu_Frame_Color,
  48.                     Menu_Title_Color, Menu_Text_Color, 'View A File' );
  49.  
  50.                                    (* Get name of file to list *)
  51.    TextColor( Menu_Text_Color_2 );
  52.    WRITELN;
  53.    WRITELN('Enter name of file to view: ');
  54.    WRITE  ('>');
  55.    TextColor( Menu_Text_Color );
  56.    IF Name_Given THEN
  57.       WRITE( View_File_Name )
  58.    ELSE
  59.       Read_Edited_String( View_File_Name );
  60.    WRITELN;
  61.  
  62.    TextColor( Menu_Text_Color_2 );
  63.  
  64.    View_File_Open := FALSE;
  65.                                    (* Ensure file exists ... *)
  66.  
  67.    IF LENGTH( View_File_Name ) > 0 THEN
  68.       BEGIN  (* View_File_Name > 0 *)
  69.  
  70.          View_File_Size := Get_File_Size( View_File_Name , View_File_Open );
  71.  
  72.          IF ( NOT View_File_Open ) THEN
  73.             BEGIN (* Int24Result <> 0 *)
  74.                WRITELN('Can''t open file ',View_File_Name,' for viewing.');
  75.                Press_Any;
  76.             END   (* Int24Result <> 0 *)
  77.  
  78.                                    (* ... and file is not empty *)
  79.  
  80.         ELSE IF ( View_File_Size <= 0  ) THEN
  81.             BEGIN  (* File is empty *)
  82.                WRITELN('File ',View_File_Name,' is empty.');
  83.                Press_Any;
  84.                View_File_Open := FALSE;
  85.             END    (* File is empty *)
  86.  
  87.         ELSE                       (* List the file *)
  88.  
  89.            List_One_File( View_File_Name );
  90.  
  91.       END  (* View_File_Name > 0 *);
  92.  
  93.                                    (* Restore previous screen *)
  94.  
  95.    Restore_Screen_And_Colors( Saved_Screen );
  96.  
  97.    Do_Status_Time := Save_Do_Status_Time;
  98.  
  99. END   (* View_A_File *);
  100.