Fail Variable declaration sintax from manual

Hi,

If i copy and paste this code on a terminal of CCR1009 with routeros 6.47.7 it fails, but on the manual it says it it the correct sintax https://wiki.mikrotik.com/wiki/Manual:Scripting#Variables:

:local myVar;
:set myVar "my value";
:put $myVar;
log info $myVar

this is the output from the terminal:

admin@Router] > :local myVar;
[admin@Router] > :set myVar "my value";
syntax error (line 1 column 6)
[admin@Router] > :put $myVar;

What is wrong here, why can’t I set my value to myvar?

:set $myVar “my value”;

Thank you, you’ve saved “half” of my day, hope mikrotik will fix it also in the wiki.
Now the var can be set, but next row :put alway is empty.

local variable lives only inside scope, and each command line is in its own scope.
Either put whole script in curly braces or use global variable

and :set $var value does not solve the actual problem either.

Thank you, this way all seems to work:

 [ :set $myVar "my value"; log info $myVar ]

You should use curly brackets, not square brackets. So correct code:

{ :local myVar; :set myVar "my value"; :log info $myVar; }

Or

{ 
  :local myVar
  :set $myVar "Some data"
  :put $myVar
  :log info $myVar
}

Both :set myVar “my value” and :set $myVar “my value” does work fine.