From cf87be70f9836bfcf93ef33f4f2cb3eb5f431697 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 26 Feb 2021 16:01:39 +0100 Subject: [PATCH] mode-button: use $ValidateSyntax --- mode-button | 25 +++++++++++++++---------- 1 file 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; }