Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
TIME$ Function and TIME$ Statement Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
' This example uses the TIME$ function to display the computer's current
' system time. The TIME$ statement is then used to reset the system's time
' based on user input.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
DO UNTIL answer$ = "y"
CLS ' Clear the screen
PRINT "The current time is: " + TIME$
PRINT
DO
INPUT "Enter the hour: ", hour$
LOOP UNTIL (VAL(hour$) < 24 AND VAL(hour$) >= 0)
DO
INPUT "Enter minutes: ", minutes$
LOOP UNTIL (VAL(minutes$) < 60 AND VAL(minutes$) >= 0)
DO
INPUT "Enter seconds: ", seconds$
LOOP UNTIL (VAL(seconds$) < 60 AND VAL(seconds$) >= 0)
TIME$ = hour$ + ":" + minutes$ + ":" + seconds$
LOCATE 10, 1
PRINT "The new time is: " + TIME$
INPUT "Is this ok (y/n)? ", answer$
LOOP