Home AMX User Forum NetLinx Studio

How to get master controller's time?

We can use the following command to set the controller's time

SEND_COMMAND 0,"'CLOCK 04-12-05 09:45:31'"

Also there is one command to get the time from controller, "time_to_hour" and "time_to_minute".
When I tried to display the time using another variable, I'm getting some symbols.

The way did is as follows. Is it correct or can anyone suggest me another method

ClockHour=time_to_hour(Time)
ClockMinute=time_to_minute(Time)

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    arunmohan wrote: »
    Also there is one command to get the time from controller, "time_to_hour" and "time_to_minute".
    When I tried to display the time using another variable, I'm getting some symbols.

    The way did is as follows. Is it correct or can anyone suggest me another method

    ClockHour=time_to_hour(Time)
    ClockMinute=time_to_minute(Time)
    It sounds like you are trying to display an integer in which case you’ll need to convert that integer to an ASCII representation first by using ITOA() or FORMAT().

    For example:
    DEFINE_DEVICE
    
    dvTP = 10001:1:0
    
    DEFINE_VARIABLE _
    
    VOLATILE SINTEGER ClockHour
    VOLATILE SINTEGER ClockMinute
    
    DEFINE_EVENT
    
    BUTTON_EVENT[dvTP,1] {
    
       PUSH: {
    
          ClockHour=time_to_hour(Time)
          ClockMinute=time_to_minute(Time)
    
          IF (ClockMinute=1) {
    	 SEND_COMMAND dvTP,"'^TXT-1,0,It is 1 minute past the hour of ',ITOA(ClockHour)"
          }
          ELSE {      
    	 SEND_COMMAND dvTP,"'^TXT-1,0,It is ',ITOA(ClockMinute), ' minutes past the hour of ',ITOA(ClockHour)"
          }
          
       }
    
    }
    
    
  • Thanks

    Thanks, Joe Hebert
Sign In or Register to comment.