1. How do I find the date and time in a Windows Program?
Use Time which returns the current date and time in the format YYYY-MM-DD
hh:mm:ss.dddd where YYYY MM DD are the year, month and date, and hh mm ss dddd
are hours, minutes, seconds and decimal places (1/10,000s of a second). Assuming the computer's
clock is set correctly, the time available to a Microsoft Windows program is accurate to about 50mS
(50/1000 of a second). This date/time format also allows time strings to be compared using the
relational operators and is the same format used by the Filetime function. The 24 hour clock
is used, so midnight is represented by hours and minutes equal to 00:00, and one minute to midnight
by 23:59. For example:
// Timedemo.cls
Ubercode 1 Class Timedemo
public function main()
code
call Msgbox("Time", Time())
end function
end class
2. How do I make a program pause for a set period?
Use the Delay function which pauses for a fixed number of seconds. Fractional parts of a
second can be used, and the delay is accurate to within about 50mS (50/1000 of a second). The next
example makes a bleep noise, separated by a delay of 1.0 seconds:
// Delayprg.cls
Ubercode 1 Class Delayprg
public function main()
var
i:integer(0:MAXINT)
code
for i from 1 to 5
call Sound("")
call Delay(1.0)
end for
end function
end class
|