Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MikroTik RouterOS scripting: passing parameters a dollar at the end of the string requires parenthesis around the string. No need when initialising variables.
-----------------------------start
value='^scripts.Function..*'
value='^scripts.Function..*$'
value='^scripts.Function..*$'
value='$'
value='$'
-----------------------------finish
{
:local showValuesFromDirectInitilisation do={
:local value1 "^scripts.Function..*"
:local logLine1 "value='$value1'"
:put $logLine1
:local value2 "^scripts.Function..*\$"
:local logLine2 "value='$value2'"
:put $logLine2
:local value3 ("^scripts.Function..*\$")
:local logLine3 "value='$value3'"
:put $logLine3
:local value4 "\$"
:local logLine4 "value='$value4'"
:put $logLine4
:local value5 ("\$")
:local logLine5 "value='$value5'"
:put $logLine5
}
:put "-----------------------------start"
$showValuesFromDirectInitilisation
:put "-----------------------------finish"
}
# showValuesFromParameters
{
:local showValue do={
:local logLine "value='$value'"
:put $logLine
}
## fails each line that ends after \$" with a `syntax error (line 12 column 4)` (the line numbers vary)
:put "-----------------------------start"
$showValue value="^scripts.Function..*"
$showValue value="^scripts.Function..*\$"
$showValue value=("^scripts.Function..*\$")
$showValue value="\$"
$showValue value=("\$")
:put "-----------------------------finish"
}
-----------------------------start
value='^scripts.Function..*'
value='^scripts.Function..*$'
value='$'
-----------------------------finish
# showValuesFromParameters
{
:local showValue do={
:local logLine "value='$value'"
:put $logLine
}
:put "-----------------------------start"
$showValue value="^scripts.Function..*"
$showValue value=("^scripts.Function..*\$")
$showValue value=("\$")
:put "-----------------------------finish"
}
-----------------------------start
value='^scripts.Function..*'
value='^scripts.Function..*$'
value='^scripts.Function..*$'
value='$'
value='$'
-----------------------------finish
{
:local showValuesFromSetInitilisation do={
:local value
:local logLine
:set $value "^scripts.Function..*"
:set logLine "value='$value'"
:put $logLine
:set $value "^scripts.Function..*\$"
:set logLine "value='$value'"
:put $logLine
:set $value ("^scripts.Function..*\$")
:set logLine "value='$value'"
:put $logLine
:set $value "\$"
:set logLine "value='$value'"
:put $logLine
:set $value ("\$")
:set logLine "value='$value'"
:put $logLine
}
:put "-----------------------------start"
$showValuesFromSetInitilisation
:put "-----------------------------finish"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.