1. What are variables good for?
Variables - are sort placeholders, thery work in the same way as the well known environment variables known from Empirum or DOS.
Writing the name of such a variable in a script is like the name of a "box with content".
At runtime of the script, the name of the box is replaced by the content that is assigned to this box.
2. Variables with the MPR
For example, while an environment variable may be called "VM_SERIAL," variables in the Package Robot are always built as follows:
Code: Select all
$$ABC
The variables: $$ABC and $$abc are thus the same variable. As well $$123 or $$A11 would be valid variable names.
How do you assign such a variable to a value, for example a serial number?
Its easy:
Code: Select all
VAR\$$ABC=1234-56768-0987
The MPR will then insert the serial number at that place.
For example:
Code: Select all
RST\$$ABC
Code: Select all
MBX\The Content is:$$ABC
Code: Select all
MBX\The Content is:$crlf$$$ABC
Now we know how to use the MPR variables.
But how do the Environment Variables come into play?
For this we have several MPR-commands:
But to simply transfer the value of an environment variable to an MPR variable, we only need the EVG\ command."EVG\[Daten]" für "EnvironmentVariableGet",
"EVS\" für "EnvironmentVariableSet",
"IEE\[Daten]" für "IfExistsEnvironmentvariable",
and "EEE\" für "EndExistsEnvironmentvariable",
"ESE\[Daten]" für "EnvironmentStringExpand",
"ESG\" für "EnvironmentStringGet",
"ESS\" für "EnvironmentStringSet".
Let's assume that our environment variable is "VM_SERIAL" (thanks for the tip, Hendrik!) And we want to transfer the value to the MPR variable "$$VMS" for later use in the script. We do like this:
Code: Select all
EVG\VM_SERIAL
VAR\$$VMS=$v1$
Now we can use the $$VMS in the script everywhere instead of text - or together with text.
For example with:
Code: Select all
SBT\10|The Serial Code is: $$VMS
And how do we pass a return code back to Empirum?
Like this:
Code: Select all
SRV\[Number or Variable]
Code: Select all
SRV\1
Using all these Variables, Scirpts can easily be modified at a later time. And in result we have all the possibilities in our script.