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

Time Function

Description

Returns a string representing the current time.

Syntax

Time[$]

Comments

The Time function returns an eight character string. The format of the string is "hh:mm:ss" where hh is the hour, mm is the minutes and ss is the seconds. The hour is specified in military style, and ranges from 0 to 23.

The dollar sign, "$", in the function name is optional. If specified, the return type is String. If omitted, the function will return a Variant of vartype 8 (String).

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

Date Function

Date Statement

Time Statement

Timer Function

TimeSerial Function

TimeValue Function