Using Date/Time in AS program

  • Hi.
    I'm pretty much a novice at AS programming but want to make use of the date and time in some of my AS programs.
    The 'TIME' function doesn't seem to work when called from a program though.
    Has anyone managed this? Or got any ideas how to do it?
    Thanks in advance for any help.

  • Hi Alexandru, What I want to do is somehow get the real time and date from the TIME function so that I can use it in an AS program.
    Perhaps to make the robot perform certain functions at certain times. I don't think the TIMER function will be suitable...

  • You can use the $DATE function in order to returns the system date in the specified string format and $TIME function in order to returns the system time in hh:mm:ss string format. For more details you can read in AS Language Reference Manual.

  • Problem is that whilst the TIME and DATE functions work after the command prompt, they don't work when typed into an AS program.
    The compiler just thinks they are variables....

  • Here is a short code in order to test. Please note that $TIME and $DATE return a string format. Therefore, a1 is a string variable ( the sign $ in front of the variable indicate the string format). Replace hh:mm:ss with your desired time. The same way you can do with the $DATE function.


    10 $a1 = "hh:mm:ss"
    IF $a1 ==$TIME THEN
    CALL subroutine
    END
    GOTO 10


    Hope that this is what you are looking for.

  • Thanks for your help Alexandru.
    That's got me sorted!
    I'd made a novice type mistake.
    I knew the time/date was returned as a string but had failed to put a $ in front of it...

Advertising from our partners