Community discussions

MikroTik App
 
A9691
newbie
Topic Author
Posts: 25
Joined: Sat May 14, 2016 10:58 am

Neither local nor global variable

Sat Jan 20, 2024 7:45 pm

I accidentally wrote $ in front of the variable name in a :set statement and it worked:
:set $notdeclared 10
I use this in a function to set the default value of an optional argument:
:global myfun do={
	:if ([:typeof $optarg] = "nothing") do={ :set $optarg "default value"}
	:return $optarg
	}
But also works in .rsc files:
:put $myvariable
:set $myvariable 10
:put $myvariable
Can somebody give some information about this feature?

(tested on Ros 6.25 and 7.7)
 
infabo
Long time Member
Long time Member
Posts: 695
Joined: Thu Nov 12, 2020 12:07 pm

Re: Neither local nor global variable

Sun Jan 21, 2024 10:42 am

 
infabo
Long time Member
Long time Member
Posts: 695
Joined: Thu Nov 12, 2020 12:07 pm

Re: Neither local nor global variable

Sun Jan 21, 2024 10:44 am

"Undefined variables will be marked as undefined and will result in a compilation error"
https://help.mikrotik.com/docs/display/ ... on%20error
 
A9691
newbie
Topic Author
Posts: 25
Joined: Sat May 14, 2016 10:58 am

Re: Neither local nor global variable

Sun Jan 21, 2024 12:59 pm

"Undefined variables will be marked as undefined and will result in a compilation error"
https://help.mikrotik.com/docs/display/ ... on%20error
Nope, just try the code.

Who is online

Users browsing this forum: robertoocabal and 8 guests