1. Starting Guide

<< Click to Display Table of Contents >>

Navigation:  1. Starting Guides >

1. Starting Guide

1.5.1.2. Using Variables

Previous Top Next


Starting Guide

 

Using Variables

 

There are two sorts of variables: global and local

 

clip0523

 

Please prefer using the SAV. and RES. command before using "local variables". In fact they are not more needed and more or less obsolete.

Yet they will be supported for compatibility.

 

 

VAR.$$TXT = VALUE

command|Target-side|   |value-side

 


Update: Due to the new SAV.Save and SAV.Restore Command the use of §§XXX-Variables (Script-local Variables) is not more recommended.

Just use the normal $$XXX (Global Variables) and make them "local" using the SAV.-Command.


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.


 

$$xxx for global variables

Global variables keep their value anywhere in a script or subscript.

 

§§xxx for script-local variables

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:


Variable-names:

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

 

Variable-names have a fixed length. Therefore we do not need any concatenation characters like in other scripting systems.

The variable-content can be any size, depending on the free memory in the windows system (memory fragmentation may play a role).

As a rule of thumb: several 100 MB should never be a problem.

 

There are few Variables which are reserved for Special Purposes which shall not be used for regular operations. Many Commands do return results directly into variables.

 

You can DUMP all currently used variables using the DMP.-Command.

 

' Dump Global Variables

DMP.2

MBX.Ready?

ENR.

 

' Dump Local Variables

DMP.3

MBX.Ready?

ENR.

 

For more Details see the DMP. Command.

 


When using the VAR.- type Commands,variable, Special-Folders and Systemvariables will be resolved!. The VAO. command for example does not resolve special folders or system-variables. If you choose VAB. the nothing will be resolved on the value-side.

 

 

 

Syntax

 

$$xxx global Variable

§§xxx  Script local Variables (local to Scripts until "ENR.")

 

 

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.

 

Please prefer using the SAV. and RES. command before using "local variables". In fact they are not more needed and more or less obsolete.

Yet they will be supported for compatibility.

 

 

See also:

 

·     The : - Definiton-Command

·     VAR. - Variable Set Value/Clear

·     VAB. - Variable Binary

·     VAC. - Variable reCt

·     VAN. - Variable Numeric

·     VAO. - Variable Once

·     VAP. - Variable Point

·     VAS. - Variable with String

·     VBA. - Variable Binary Append

·     OPT. - Optional Settings