Community discussions

MikroTik App
 
Michael12345
Member Candidate
Member Candidate
Topic Author
Posts: 139
Joined: Wed Oct 28, 2009 8:44 am

Ros4.02bet verson set a variable can't work?

Wed Oct 28, 2009 9:02 am

like this: if I type ":set i 50" in the teiminal as usual previous verson, the variable "i" become to display brown, means error. No matter what i have tried ,it can''t work, why ? Who can tell me how to set a variable in verson 4.02? Thanks a lot.
You do not have the required permissions to view the files attached to this post.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7211
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Ros4.02bet verson set a variable can't work?

Wed Oct 28, 2009 9:26 am

Every variable must be declared before usage. Please read the manual:
http://wiki.mikrotik.com/wiki/Scripting#Variables
 
Michael12345
Member Candidate
Member Candidate
Topic Author
Posts: 139
Joined: Wed Oct 28, 2009 8:44 am

Re: Ros4.02bet verson set a variable can't work?

Wed Oct 28, 2009 3:04 pm

I have declared,but it remained,It seems like a bug , and i have tangled it two days! /Who can tell me why ??? Did anybody ever encounter it before ?
You do not have the required permissions to view the files attached to this post.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7211
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Ros4.02bet verson set a variable can't work?

Wed Oct 28, 2009 3:06 pm

Each command line is separate script, so local variable is not defined in second line.
To make this work use {}
{
:local test 1;
:put $test;
}
 
Michael12345
Member Candidate
Member Candidate
Topic Author
Posts: 139
Joined: Wed Oct 28, 2009 8:44 am

Re: Ros4.02bet verson set a variable can't work?

Wed Oct 28, 2009 3:57 pm

Thanks very much. But it seems can work in version2.927. the change between version2.9 and 4.X is a lot.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7211
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Ros4.02bet verson set a variable can't work?

Wed Oct 28, 2009 4:01 pm

Yes, there are a lot of changes.
Scripting manual has all the information to start writing scripts
http://wiki.mikrotik.com/wiki/Scripting
You can check also scripting examples
http://wiki.mikrotik.com/wiki/Scripting-examples