Kbase P18852: How to get the size of any file regardless of version or OS
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  05/02/2003 |
|
Status: Unverified
GOAL:
How to get the size of a file WITHOUT the FILE-INFO:FILE-SIZE Attribute?
FACT(s) (Environment):
Progress 6.x
FACT(s) (Environment):
Progress 7.x
FACT(s) (Environment):
Progress 8.x
SYMPTOM(s):
Unable to use FILE-INFO:FILE-SIZE attribute in 8.3E and earlier versions.
CAUSE:
The FILE-INFO:FILE-SIZE attribute was introduced in version 9. Hence it is not available in lower versions.
FIX:
The solution code uses the 4GL SEEK statement to position the file pointer to the last byte of the file and then uses the 4GL SEEK function to return the size of the file in bytes.
/*File Size regardless of version of platform*/
DEFINE VARIABLE iFileSize AS INTEGER NO-UNDO.
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
DEFINE STREAM myStream.
ASSIGN
iFileSize = 0
cFileName = "myFile.txt".
INPUT STREAM myStream FROM VALUE(cFileName).
SEEK STREAM myStream TO END.
iFileSize = SEEK(myStream).
INPUT STREAM myStream CLOSE.
MESSAGE iFileSize
VIEW-AS ALERT-BOX INFO BUTTONS OK.
/**********************************************/