diff options
author | Christian Hesse <mail@eworm.de> | 2021-02-26 16:01:39 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2021-02-26 16:01:39 +0100 |
commit | cf87be70f9836bfcf93ef33f4f2cb3eb5f431697 (patch) | |
tree | 96d10af34155ae216f67e629dc70a823795e14c3 | |
parent | e76b52e3b08d1e66c47a067040071ffb95b1b528 (diff) |
mode-button: use $ValidateSyntax
-rw-r--r-- | mode-button | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/mode-button b/mode-button index 8d96fcd..e2da374 100644 --- a/mode-button +++ b/mode-button @@ -25,6 +25,7 @@ :global LogPrintExit2; :global ModeButtonScheduler; + :global ValidateSyntax; :local LEDInvert do={ :global ModeButtonLED; @@ -46,19 +47,23 @@ / system scheduler remove ModeButtonScheduler; :if ([ :len $Code ] > 0) do={ - $LogPrintExit2 info $0 ("Acting on " . $Count . " mode-button presses: " . $Code) false; + :if ([ $ValidateSyntax $Code ] = true) do={ + $LogPrintExit2 info $0 ("Acting on " . $Count . " mode-button presses: " . $Code) false; - :for I from=1 to=$Count do={ - $LEDInvert; - :if ([ / system routerboard settings get silent-boot ] = false) do={ - :beep length=200ms; + :for I from=1 to=$Count do={ + $LEDInvert; + :if ([ / system routerboard settings get silent-boot ] = false) do={ + :beep length=200ms; + } + :delay 200ms; + $LEDInvert; + :delay 200ms; } - :delay 200ms; - $LEDInvert; - :delay 200ms; - } - [ :parse $Code ]; + [ :parse $Code ]; + } else={ + $LogPrintExit2 warning $0 ("The code for " . $Count . " mode-button presses failed syntax validation!") false; + } } else={ $LogPrintExit2 info $0 ("No action defined for " . $Count . " mode-button presses.") false; } |