Counting
staticattic
Posts: 200
I think I am having a total brain dump or a nervous breakdown or something. I need to fetch a variable, and everytime the user presses a button, that number will increase by one. I am allowing them to set the clock via the touch panel. When they enter the clock settings screen, the current time is displayed. I am capturing that like so:
nHours = ATOI(LEFT_STRING(TIME,2))
nMinutes = ATOI(MID_STRING(TIME,4,2))
That works fine. What I need to now do is allow them to push the hour up or down button and have it increment or decrement the hour by one each button press. After they are done setting the clock, I was going to send the new variables (nHours and nMinutes) to the NetLinx as the new time using this format:
SEND_COMMAND <DEV>,"'CLOCK <mm-dd-yy> <hh:mm:ss>'"
A simple up counter should only take like 5 minutes to write. Maybe I am just tired. I currently have it set up as a FOR loop, but I can't remember how to get it to stop and wait until the button is pressed again. Right now, it goes through the whole thing auomatically.
nHours = ATOI(LEFT_STRING(TIME,2))
nMinutes = ATOI(MID_STRING(TIME,4,2))
That works fine. What I need to now do is allow them to push the hour up or down button and have it increment or decrement the hour by one each button press. After they are done setting the clock, I was going to send the new variables (nHours and nMinutes) to the NetLinx as the new time using this format:
SEND_COMMAND <DEV>,"'CLOCK <mm-dd-yy> <hh:mm:ss>'"
A simple up counter should only take like 5 minutes to write. Maybe I am just tired. I currently have it set up as a FOR loop, but I can't remember how to get it to stop and wait until the button is pressed again. Right now, it goes through the whole thing auomatically.
0
Comments
// Better Way
nHours = TIME_TO_HOUR(TIME);
nMinutes = TIME_TO_MINUTE(TIME);
even better, when using a G4 panel, just copy the buttons from the setup page, and you are done in < 1 minute
You get an A++++++++++++++++++
i always do