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.

Every variable must be declared before usage. Please read the manual:
http://wiki.mikrotik.com/wiki/Scripting#Variables
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 ?

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;
}
Thanks very much. But it seems can work in version2.927. the change between version2.9 and 4.X is a lot.
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