I have a app associating image files with jobs. I have sorted getting file date & time, long name and and short name using Clarion, but have not found a method of getting the file size. Are there any suggestions?
! Get image details
!------------------
! File Name (without path)
IF ALC:OriginalFile <> ''
LX# = LEN(CLIP(ALC:OriginalFile))
LOOP X# = LX# TO 1 BY -1
IF ALC:OriginalFile[X#] = '\'
BREAK
END
END
IF ALC:OriginalFile[1 : (X#-1)] = LONGPATH(PATH())
ALC:StoredImageName = UPPER(ALC:OriginalFile[(X#+1) : LX#])
DISPLAY(ALC:StoredImageName)
END
END
! Short 8.3 file name
ALC:OriginalShortName = SHORTPATH(ALC:StoredImageName)
DISPLAY()
! File Extension
LocationOfFullStop# = instring('.',ALC:OriginalFile)
IF (LocationOfFullStop#>0)
LengthOfFullFileName# = Len(ALC:OriginalFile)
NumCharactersOfExtension# = LengthOfFullFileName# - LocationOfFullStop#
LOC:FileExtn = UPPER(SUB(ALC:OriginalFile, LocationOfFullStop#+1, NumCharactersOfExtension#))
END
ALC:ImageDate = GETFILEDATE(ALC:OriginalFile)
ALC:ImageTime = GETFILETIME(ALC:OriginalFile)
ALC:Size = ALC:OriginalFile{PROP:FileSize}
LOC:ImageSizeMB = (ALC:Size / 1000000)
ALC:StoredImage = ALC:OriginalFile
DISPLAY()
NOTE…Indentation corrected, thank you, Julian: Indentation of the code was lost when pasting into this question!
You may want to use the Clarion “Bytes(File), Long” to get the size when the size is not bigger than 2,147,483,647 (max value for a Long).
BYTES Returns number of bytes in FILE, or most recently read.
file The label of a FILE.
The BYTES procedure returns the size of a FILE in bytes or the number of bytes in the last record successfully accessed. Following an OPEN statement, BYTES returns the size of the file. file{PROP:FileSize} is equivalent to BYTES after a file open and will also return the size of the file. After the file has been successfully accessed by GET, REGET, NEXT, PREVIOUS, ADD, or PUT, the BYTES procedure returns the number of bytes accessed in the RECORD. The BYTES procedure may be used to return the number of bytes read in a variable length record.
In SQL tables, if BYTES(file) is used before the file is opened, then it returns the number of rows in the table. If it is used after the file is opened and a successful record retrieval, it returns the number of bytes in the record buffer.