Hello.
I study mikrotik script.
what’s wrong.JPG
I input :local variable and print value but I can’t see value
Am I wrong?
I refer wiki site but my result is not same.
Hello.
I study mikrotik script.
what’s wrong.JPG
I input :local variable and print value but I can’t see value
Am I wrong?
I refer wiki site but my result is not same.
Each line written in terminal is treated as local scope.
Try this in terminal:
:local hello 8 ; :put $hello
8
That will work but not:
:local hello 8
:put $hello
In scripts the local scope is within the curly braces { }
thanks for replying!
So this wiki example is wrong?
http://wiki.mikrotik.com/wiki/Set_global_and_local_variables
I see some script example, the local variable aren’t in {} scope.
I’m so confused here’s another link
http://wiki.mikrotik.com/wiki/Script_to_create_directory
Yeah, both examples are wrong. Can’t use local vars like that.
In winbox, go to “System/Scripts”, you can monitor the global variables from the Enviroment tab. Very handy when learning or debugging. Even the variables that you declare in the CLI will appear here.