GetFileTimes Method (RUNTIME)


10.6A

The GetFileTimes method retrieves the OS date and time that a file was created, last accessed, and last modified. This method uses the following format:

 

[label]

{object}.GetFileTimes

[GIVING {return}] USING [*FILENAME=]{filename}[:

 

 

[*CREATETIME=]{createtime}][:

 

 

[*ACCESSTIME=]{accesstime}][:

 

 

[*WRITETIME=]{writetime}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A RUNTIME object.

return

Optional. A Character String Variable that receives the current directory name and path being used by the RUNTIME object.

filename
Required. A Character String Variable or literal that specifies the fully qualified filename to be used.
createtime
Optional. A PL/B DATETIME object that receives the creation time for the specified file.
accesstime
Optional. A PL/B DATETIME object that receives the last access time for the specified file.
writetime
Optional. A PL/B DATETIME object that receives the last write time for the specified file.

Flags Affected: EOS, OVER, ZERO

Note the following:

  1. The EOS flag is always set to FALSE.

  2. The ZERO flag is set to be TRUE if the {return} value is zero. Otherwise, the ZERO flag is set to be FALSE.

  3. The OVER flag is set to be TRUE if the {return} variable is too small to receive the method result without truncation. Otherwise,The OVER flag is set to be FALSE.

  4. If the method executes successfully, the {return} value is zero. If the method fails, the {return} value is a non-zero value described as follows:

  5.  

    Return Value

    Description

    1

    The GetFileTimes method is not supported by the PL/B runtime.

    nnnn

    Windows OS error code values. See the 'Sunbelt PL/B Runtime Reference' under "Error Messages\O/S Error Codes".

     

  6. Example:

 

Run

RUNTIME

//Windows ONLY!

CTime

DATETIME

 

ATime

DATETIME

 

WTime

DATETIME

 

Dx

DIM

80

Dall

DIM

200

nVar

FORM

2

Result

FORM

8

x0A

INIT

0x0A

.

 

 

 

CTime.SetToNow

 

 

ATime.SetToNow

 

 

WTime.SetToNow

 

.

 

 

 

Run.GetFileTimes

GIVING Result:

 

 

USING *FILENAME="c:\temp\xfile.txt":

 

 

*CREATETIME=CTime:

 

 

 *ACCESSTIME=ATime:

 

 

*WRITETIME=WTime

 

IF

ZERO

.

 

 

 

CTime.GetAsString

GIVING Dx //Use default format!

 

PACK

Dall, "Create time: ", Dx, x0A

.

 

 

 

ATime.GetAsString

GIVING Dx //Use default format!

 

PACK

Dall, Dall, "Access time: ", Dx, x0A

.

 

 

 

WTime.GetAsString

GIVING Dx //Use default format!

 

PACK

Dall, Dall, "Write time: ", Dx

 

 

 

 

REPLACE

"T Z ", Dall //Remove delimiters!

 

ALERT

NOTE, Dall, nVar, "GetFileTimes Ok!"

.

 

 

 

ELSE

 

.

 

 

 

PACK

S$CMDLIN, "GetFileTImes Error: ", Result

 

ALERT

NOTE, S$CMDLIN, nVar, "GetFileTimes Failure!"

.

 

 

 

ENDIF

 

 

 

See Also: RUNTIME, RUNTIME Methods, Method Syntax

 



PL/B Language Reference GetDir Method (RUNTIME) GetInfo Method (RUNTIME)