1.5.3 More about Variables

<< Click to Display Table of Contents >>

Navigation:  1. Starting Guides >

1.5.3 More about Variables

1.5.1.2.1 Using Variables

Previous Top Next


Starting Guide

 

Variable Resolution

 


 

At some point the Robot will resolve the variables to their content.

During this topic, the content of the variables can contain more variables that may be also resolved or not depending on which commands you use.

 

clip0522

Often variables are visualized as boxes that can contain something.

 

What is "variable resolution"?

 

It is the process, when a variable-name in the script is replaced with the variable-content.

In fact this is why variables are used.

 

Variable-resolution is: the robot takes the variable-name and replaces it with the variable content.

 

Generally the process is simple, but it can be more difficult in few cases. Let us see an example:

 

VAR.$$TXT=Computer

VAR.$$LIN=$$TXT

' Write the content of $$LIN in the Editor-Debug window

DBV.$$LIN

 

In this example, we first tell the robot that the variable $$TXT means "Computer".

In the second line, we tell it that $$LIN is the same as $$TXT, which means that $$LIN is also "Computer".

Looks easy. Is easy.

 

 

Resolving multiple variables

Lets make it a bit more tricky for the robot. What will the SPR do, if there are many variables in a variable?

 

' First we define three variables

VAR.$$TXA=Computer

VAR.$$TXB=Software

VAR.$$TXC=Center

 

' Now we assign them to $$LIN

VAR.$$LIN=$$TXA$$TXB$$TXC

 

' Write the content of $$LIN in the Editor-Debug window

DBV.$$LIN

 

The output is as expected:

 

graphic

 

 

VAR. resolved all the variables.

Now lets go one step ahead. What will happen, if there will be variables inside these variables?  Will they also be resolved?l

To do this we use a special Command, that is VAB. This Command will just take the right side and not go through a variable-resolution.

 

' First we define three variables

' Note that i have used VAB. instead of VAR.

VAB.$$TXA=Computer

VAB.$$TXB=$$TXA

DBV.Variable TXB contains >$$TXB<

' Here we use VAR. again

VAR.$$LIN=$$TXB

' Write the content of $$LIN in the Editor-Debug window

DBV.Variable LIN contains: <$$LIN>

ENR.

 

What do we expect to get here?

$$TXB contains $$TXA

and that is the result that we get.

 

graphic

 

VAR. will resolve all variables on the first level, to be as binary compatible as possible, it will not make a "deep resolution".

Because this way, binary content inside a variable is safe. If you want a "deep resolution" choose VAV. instead.

 

Let us give it a try:

 

' First we define three variables

' Note that i have used VAB. instead of VAR.

VAB.$$TXA=Computer

VAB.$$TXB=$$TXA

DBV.Variable TXB contains >$$TXB<

' Here we use VAV. to get a deep resolution

VAV.$$LIN=$$TXB

' Write the content of $$LIN in the Editor-Debug window

DBV.Variable LIN contains: <$$LIN>

ENR.

 

This is the result:

 

graphic

 

 

Now when we deal with text this is mostly an less important issue. Variable resolution becomes important when we deal with files that contain elements that could possibly be resolved.

 

For example, you want to have the phrase "$$TXT is not 99" in a Variable $$LIN.

If you try this:

 

VAR.$$TXT=Computer

VAR.$$LIN=$$TXT is not 99

 

then $$TXT will immediately be resolved to "Computer" and you do not get what you want.

Therefore we have a couple of different VAR.-commands with different behavior about variable-types and variable-resolution.
If you use VAB. instead of VAR. it will work.

 

VAR.$$TXT=Computer

VAB.$$LIN=$$TXT is not 99

' Output Variable to Editor

DBV.$$LIN

 


Important!

How do you get the §-Character on non-german Keyboards?

 

Press "ctrl-B".

The SPRE-Editor will give you the § character when you press left "Ctrl" and "B" on your keyboard.

 

Pressing "ctrl-H" will give you the | (Pipe) Character.

 


 

Here are some of the different Methods to assign values to variables.

 

    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