Variables and Environment-Variables using the MPR

Moderator: MVogt

Post Reply
User avatar
Theo_Gottwald
Posts: 367
Joined: 03. Oct 2009, 08:57
Location: Herrenstr.11 * 76706 Dettenheim
Contact:

Variables and Environment-Variables using the MPR

Post by Theo_Gottwald » 31. Jan 2019, 09:29

VARIABLES are an universal concept that is also implemented in the MPR.

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
We use twice the "$" and then three letters (or numbers). Upper and lower case are not distinguished.
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
You can now use the variable anywhere in the script, where else the assigned text would be used.
The MPR will then insert the serial number at that place.

For example:

Code: Select all

RST\$$ABC
If you want to control the content of a variable, you can display a message box:

Code: Select all

MBX\The Content is:$$ABC
or something more clean, with a linefeed:

Code: Select all

MBX\The Content is:$crlf$$$ABC
3. Environment Variables
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:
"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".
But to simply transfer the value of an environment variable to an MPR variable, we only need the EVG\ command.

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
We can also mix text with variables. Unlike VB-Script we do not need any "" chaining characters (&, +). The reason for this is the fixed length of the MPR variables . As a result, the robot knows exactly where a variable starts and where it ends.

And how do we pass a return code back to Empirum?
Like this:

Code: Select all

SRV\[Number or Variable]
So for example:

Code: Select all

SRV\1
would trigger the errorlevel 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.

Post Reply

Return to “Package Robot”

Who is online

Users browsing this forum: No registered users and 1 guest