home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / GETFSIZE.MOD < prev    next >
Text File  |  1987-12-02  |  3KB  |  64 lines

  1. (*----------------------------------------------------------------------*)
  2. (*           Get_File_Size --- Get size in bytes for a file             *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Get_File_Size( Fname: AnyStr; VAR OpenOK : BOOLEAN ): LONGINT;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Get_File_Size                                        *)
  10. (*                                                                      *)
  11. (*     Purpose:    Get size in bytes for a file                         *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Fsize := Get_File_Size( Fname      : AnyStr;                  *)
  16. (*                                VAR OpenOK : BOOLEAN ) : REAL;        *)
  17. (*                                                                      *)
  18. (*           Fname  --- name of file to find size of                    *)
  19. (*           OpenOK --- set TRUE if file opened successfully            *)
  20. (*           Fsize  --- file size in bytes                              *)
  21. (*                                                                      *)
  22. (*     Calls:                                                           *)
  23. (*                                                                      *)
  24. (*        RESET                                                         *)
  25. (*        Int24Result                                                   *)
  26. (*        ASSIGN                                                        *)
  27. (*        LongFileSize                                                  *)
  28. (*        Close                                                         *)
  29. (*                                                                      *)
  30. (*     Remarks:                                                         *)
  31. (*                                                                      *)
  32. (*        The file must not already be opened before calling this       *)
  33. (*        routine.                                                      *)
  34. (*                                                                      *)
  35. (*----------------------------------------------------------------------*)
  36.  
  37. VAR
  38.    F : FILE OF BYTE;
  39.    I : INTEGER;
  40.  
  41. BEGIN (* Get_File_Size *)
  42.  
  43.    Get_File_Size := 0;
  44.    FileMode      := 0;
  45.  
  46.    ASSIGN( F , Fname );
  47.    RESET ( F );
  48.  
  49.    FileMode      := 2;
  50.  
  51.    IF ( Int24Result = 0 ) THEN
  52.       BEGIN
  53.          Get_File_Size := FileSize( F );
  54.          OpenOK := TRUE;
  55.       END
  56.    ELSE
  57.       OpenOK := FALSE;
  58.  
  59.    CLOSE( F );
  60.  
  61.    I := INT24Result;
  62.  
  63. END   (* Get_File_Size *);
  64.