Consultor Eletrônico



Kbase 14175: Version 8: How to get date of text file via DLL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Version 8: How to get date of text file via DLL

How to get the date of a text file?

In version 7, You must spawn to the operating system to get
the date of a file. Here is an example of how to do this:

os-command value('ls -l ' + filename + ' | temp.lis').
input from temp.lis
import filedate.
os-delete value ('temp.lis').
display filedate.


In version 8, you can use the above example but a faster solution is
to use the fileinfo DLL that Progress provides in version 8. Here
is an example of how to do this:

{adecomm/fileinfo.i}
define var file-year as int.
define var file-mon as int.
define var file-day as int.
define var file-hour as int.
define var file-min as int.
define var file-sec as int.
define var file-size as int.
define var error as int.


define var CurFile as char no-undo init "c:\autoexec.bat".
define var StrDate as char.
define var ModDate as date.
define var ModTime as char.

run file_info (
input CurFile,
output file-year,
output file-mon,
output file-day,
output file-hour,
output file-min,
output file-sec,
output file-size,
output error).

case session:date-format:
when "dmy" then
StrDate = string(file-day,"99") + "/" +
string(file-mon,"99") + "/" +
substr(string(file-year),3,2,"fixed").
when "ymd" then
StrDate = substr(string(file-year),3,2,"fixed") + "/" +
string(file-mon,"99") + "/" +
string(file-day,"99").
otherwise assign
StrDate = string(file-mon,"99") + "/" +
string(file-day,"99") + "/" +
substr(string(file-year),3,2,"fixed").
end case.

assign
ModDate = date(StrDate)
ModTime = string(file-hour,"99") + ":" +
string(file-min,"99") + ":" +
string(file-sec,"99").

message
CurFile ModDate ModTime File-size
view-as alert-box.

Progress Software Technical Support Note # 14175