You can force the declaration of variable with the strict word:
strict;
and disable it by unstrict word:
unstrict;
Variables are declared with the var word:
var myVariable = 5;
Undefining a variable is enable by undef word:
undef myVariable;
Deleting a variable is enable by delete word:
delete myVariable;
undef and delete commands have the same behavior. THey will be unified in future versions.
Table 2.4. Variables types
| description | type |
|---|---|
| var i = 48.0000; | float type |
| var myList = [1,2,"fe"]; | list type |
| var myStr = "hello"; myStr = myStr + " world"; | string type |
| var myBinary = <params>BIN <size> <data>; | binary type |
| myObj = OBJ [x:1, y:2]; //DO NOTHING IN URBI 1.0 | object type |
| myObj = new myConstructorObj(param); | object type |
Table 2.5. Variables of type List
| command | description |
|---|---|
| var emptyList=[]; | load variable with an empty list |
| myList = [11,22] + [32,44,11] + "hello"; | add elements to a list |
| head(myList); | return the 1st element |
| tail(mLlist); | return the last elements of the list |
| size(myList); | return number of elements of the list |
| getIndex(list, index); | return element a given index in given list |
Table 2.6. Variables of type String
| command | description |
|---|---|
| strlen(myString); | return integer size of the string |
| var mySubString = strsub(myString, pos, 3); | return a string from position "pos", of length 3 |
Table 2.7. Variables of type Array
| command | description |
|---|---|
| var myArray[12] = 4; | load 12th element of array with 4 |
| var myArray__12 = 4; | same as above, load 12th element of array with 4 |
| var myMultyArray[12][5] = 4; | bidimensionnal array are available |
| var myArray["name"] = "Ted"; | Array indexed by string instead of integer, same as myArray_name = "Ted"; |
| var s = "hello $name" name:"John"; | string with parameter |
Table 2.8. Other commands for variables
| command | description |
|---|---|
| vars; | return list of all variables |
| uservars; | return list of variables for user |
| var global.myUVar = 5; | declare a global variables, for all |
| $("global.myUVar"); | return the variable |
| %global.myUVar; | return a string with the variable name |
| myVarB = copy myVarA; | do a hard copy of variable, not a pointer to it. Useful for binaries. |
| (static x == 1) | variable is locally static, if changed in another location, stay unmodified |
| var mybin = bin 2048 wav 2 16000 16 1; ######2048 data#### | declaration of a binary UVar. |
Table 2.9. Defined constants
| var | constant |
|---|---|
| pi; | return 3.14159 |
| true; | return 1 |
| false; | return 0 |
| on; | return 1 |
| off; | return 0 |