Charmed Quark Systems, Ltd. - Support Forums and Community

Full Version: Help with increase/decrease a string field.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Been out for a while busy with outside issues but getting back into my CQC now.

I have a sprinkler duration field which is reading the custom string value from my Elk M1. I want to display the current duration (300, 360, 420 seconds) and have a separate on-screen up and down button that will increment the duration by 30 seconds. I can do this with a whole array of if/than statements for each up/down button for 0 to 6000 sec (10 min) but there must be a more efficient, more elegant, solution.

thanks
robolo
Here is what I use to increase, decrease by 15 minutes on my irrigation system. The decrease button code will keep it at a minimum 15 min.

Code:
[b]Increase Button[/b]
[OnClick]
   Devices::FieldRead(Security.CustVal01, LVar:Temp, True)
   LocalVars::Add(LVar:Temp, 900)
   Devices::FieldWrite(Security.CustVal01, %(LVar:Temp), True)

[b]Decrease Button[/b]
[OnClick]
   If System::GrThan($(Security.CustVal01), 900)
      Devices::FieldRead(Security.CustVal01, LVar:Temp, True)
      LocalVars::Subtract(LVar:Temp, 900)
      Devices::FieldWrite(Security.CustVal01, %(LVar:Temp), True)
   End
Ahh,
Fantastic

Thanks