Macros and the IBM CognosScript Language  7.5.0
IBM CognosScript Statements and Functions >

FileDateTime Function

Description

Returns the last modification date and time for the specified file.

Syntax

FileDateTime( pathname$ )

where:

is:

pathname$

A string expression for the name of the file to query.

Comments

Pathname$ can contain path and disk information, but cannot include wildcards (* and ?).

Example

This example writes data to a file if it hasn't been saved within the last 2 minutes.

Sub main
   Dim tempfile
   Dim filetime, curtime
   Dim msgtext
   Dim acctno(100) as Single
   Dim x, I
   tempfile="C:\TEMP001"
   Open tempfile For Output As #1
   filetime=FileDateTime(tempfile)
   x=1
   I=1
   acctno(x)=0
   Do
      curtime=Time
      acctno(x)=InputBox _
         ("Enter an account number (99 to end):")
      If acctno(x)=99 then
         For I=1 to x-1
            Write #1, acctno(I)
         Next I
         Exit Do
      ElseIf (Minute(filetime)+2)<=Minute(curtime)then
         For I=I to x
            Write #1, acctno(I)
         Next I
      End If
      x=x+1
   Loop
   Close #1
   x=1
   msgtext="Contents of C:\TEMP001 is:" & Chr(10)
   Open tempfile for Input as #1
   Do While Eof(1)<>-1
      Input #1, acctno(x)
      msgtext=msgtext & Chr(10) & acctno(x)
      x=x+1
   Loop
   MsgBox msgtext
   Close #1
   Kill "C:\TEMP001"
End Sub

See Also

FileLen Function

GetAttr Function