File Date and Time

Status
Not open for further replies.

tgounden

New Member
Hi,

I am using Progress 83C on a Unix server in character mode. I need to get the creation date and time of a file and then inform the user of these details. Any ideas on how I can accomplish this will be highly appreciated.

Thanks
 

Robert

New Member
Check the FILE-INFO handle.

Try:
FILE-INFO:FILE-NAME = "/data/files/theFile" NO-ERROR.

And then:
DISPLAY
String (FILE-INFO:FILE-CREATE-DATE, "99/99/9999") format "X(20)"
STRING (FILE-INFO:FILE-CREATE-TIME, "HH:MM:SS") format "X(20)" .

Also, it might be worth you looking up the other attributes of FILE-INFO in the help files.

Hope this helps.

Robert
 

tgounden

New Member
Thanks Robert,

I have tried using the FILE-INFO handle attributes but I don't get the desired results. Some of the attributes work and some don't. Unfortunately it states in the documentation that the FILE-CREATE-DATE & FILE-CREATE-TIME attributes only work on the Windows platform - my Progress is on a Unix server and I access it through a terminal emulator.

I have tried using FILE-MOD-DATE and FILE-MOD-TIME but they give me the following error message when run:

"Unknown attribute FILE-mod-date used in widget:attribute phrase. (3406) ** Could not understand line 6. (196) "

How can I get around this problem.

Thanks
Terrence
 

NickA

Member
AFAIK Your average Unix system doesn't store creation date or time. Just last access and last update.
 

Robert

New Member
For what Nick says FILE-MOD-DATE and FILE-MOD-TIME would be the only available alternative for you, on UNIX.
But if this doesn't work, you could always do an
os-command("ls -l " + filename + " > /tmp/tempfile")
and then parse the contents of the file /tmp/tempfile, but I admit that this solution is less ideal...

HTH

Robert
 

NickA

Member
Another alternative

Code:
INPUT THROUGH VALUE ( "ls -l " + cFileName ).
...saves having to use an intermediate file.

Of course, this still doesn't help you with your original 'creation date' problem.

I also notice you're on 8.3, and I didn't think FILE-INFO:FILE-CREATE-DATE, FILE-CREATE-TIME, FILE-MOD-DATE and FILE-MOD-TIME were supported until V9? (I'm fully expecting to be corrected here :awink: ).
 

Robert

New Member
> I also notice you're on 8.3, and I didn't think FILE-INFO:FILE-CREATE-DATE, FILE-CREATE-TIME, FILE-MOD-DATE
> and FILE-MOD-TIME were supported until V9? (I'm fully expecting to be corrected here).

No correction needed Nick.
You're right, the attributes FILE-MOD-DATE, FILE-MOD-TIME and FILE-SIZE are version 9 only.

> Of course, this still doesn't help you with your original 'creation date' problem.

Well, the choice is last modification date/time OR nothing.... From there it's upto Terrence....
 

tgounden

New Member
Hi,

Thanks for all the responses guys - it looks like I will have to settle for the modification date and time using the Unix command.

Unfortunately I am not that clued up on Progress so I need a little more help.

How do I pass the date and time from INPUT THROUGH VALUE ( "ls -l " + cFileName ) to a variable so that I can display it.

Thanks
Terrence:rolleyes:
 

NickA

Member
Something along the lines of...

Code:
INPUT THROUGH VALUE ( "ls -l " + cFileName ).

REPEAT:

  /* Import the results of 'ls' one whole line at a time */
  IMPORT UNFORMATTED cFileDetails.

  /* Assuming file name is at position 55, try to determine if the current line */
  /* is the right one by comparing the file name */
  IF TRIM ( SUBSTRING ( cFileDetails, 55 ) ) = cFileName THEN DO:
    /* Assuming date and time last modified is at position 42 for 12 characters */
    ASSIGN cFileDate = TRIM ( SUBSTRING ( cFileDetails, 42, 12 ) ).
    LEAVE.
  END.

END.

INPUT CLOSE.
 
Status
Not open for further replies.
Top