4.3 Variables, global and local

<< Click to Display Table of Contents >>

Navigation:  2. Components > 4. Special features >

4.3 Variables, global and local

Global and local Variables

Previous Top Next


MiniRobotLanguage (MRL)

 

Variables, GLOBAL and LOCAL

 

 

 

Intention

 

Variables are Symbols which contain numerical or string-data. When used in a script, the variable name is replaced with the variable content at runtime. The variable content can be defined, changed and cleared at runtime.

 

Global Variables are valid everywhere in a Script. Local Variables are used inside "Sub-Scripts" which are called with the JNF.-Command. Local variables contain their value until the script is left to the calling script. Then their content is lost.

 

If a script calls another script using JNF., the content of its local variables is preserved and automatically restored on return from the subscript.

 

Local variables are cleared when the Script returns to the Main-Script, using RTS.

Local Variables and JNF. can be nested to unlimited depth.The Format for Variables is always:

 

§§xxx for script-local variables

 

$$xxx for global variables

 

Global variables keep their value anywhere in a script or subscript. Variables have a fixed length. Therefore we do not need any concatenation characters like in other scripting systems.

 

For xxx all letters or numbers as well as the "-" can be used.

 

There are few Variables which are reserved for Special Purposes which shall not be used for regular operations.

 

There are different Methods to assign values to variables.

 

    The : - Definiton-Command

    The VAR. - Variable Set Value/Clear

    VAB. - Variable Binary

    VAC. - Variable reCt

    VAN. - Variable Numeric

    VAO. - Variable Once

    VAP: - Variable Point

    VAS. - Variable with String

 

 

Only when using the VAR.- type Commands, Speical-Folders and System-Variables will be resolved! The Definition command does not resolve special folders.

 

Also Commands do return results directly into variables.

 

 

 

Syntax

 

$$xxx global Variable

§§xxx local Variable

 

 

Parameter Explanation

 

If the Parameter is omitted, the Variable is set to empty, which represents string with a of length 0, or a value of 0.

 

 

Example

 

' define global variable without Special-folders

: $$TXT=Hallo World

 

' define global variable with Special-folders and System-variable Resolution

VAR.$$FIL=?progs\FS Office\Myprog.exe

PRT.$$FIL

' Display a list with all global Variables

DMP.4

 

' define local variable with Special-folders and System-variable Resolution

VAR.§§FIL=?progs\FS Office\Myprog.exe

PRT.§§FIL

' Following clears variable §§NUM

: §§NUM=

' Display a list with all local Variables

DMP.5

 

 

 

Remarks

 

Global Variables are valid everywhere in a Script. Local Variables are used inside "Sub-Scripts" which are called with the JNF.-Command.

Such variables are cleared when the Script returns to the Main-Script, using RTS.

Local Variables and JNF. can be nested to unlimited depth.

 

 

Limitations:

How long can variables get? What is the maximum size? 100 MB ? 250, 500 MB ?

It depends on the amount of unfragmented Memory that the robot can get from the OS.

Under normal circumstances variables can always exceed a size of 50 or 100 MB (MegaBytes) without problems. Once you clear the variable with

VAR.$$XXX=

the memory is safely returned to the OS. Of course this happens automatically when the script ends.

 

See also: