! Smart Package Robot 's Variable Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Variable Definitions and Operations >

! Smart Package Robot 's Variable Commands

Smart Package Robot 's Variable Commands

Previous Top Next


 

Smart Package Robot 's Variable Commands

 

 

    graphic

 There are lots of Commands available to deal with Variables.

 

 

Variables simple and complex in once?

 

What are Variables?

 

Hey there! Imagine a variable like a magic box with a special name, like "$$AGE".

This box can hold different things, like numbers, words, or even secrets!

 

For example, let's say we have a variable called "$$AGE".

We can put a number, like 10, inside it. Now, "$$AGE" holds the number 10.

 

But here's the cool part: we can change what's inside our magic box. We can put 5 in it next time, and now "$$AGE" has 5 inside!

Variables help us do math and keep track of things. We can add, subtract, or do all sorts of tricks with them.

Imagine you have "$$COK" and it starts with 3 cookies inside.

You eat one, so now there are 2 cookies left in "$$COK" Variables help us keep count of things like this.

 

So, in simple words, a variable is like a magical container with a name that can hold different stuff, and we can change what's inside whenever we want.

It's super useful for computers, Scripts and even games, stories, and lots of fun stuff!

 

How do Variables look with the Smart Package Robot?

In the context of Smart Package Robot, a variable always consists of 5 characters. This fixed length eliminates the need for explicit delimiters in strings, such as in the case of  'Hello.' This design offers significant advantages, particularly when working with data formats like JSON that require delimiters.

You'll see the benefits of this when it becomes necessary.

 

Variables in Smart Package Robot have two distinct prefixes: '$$' for global variables and '§§' for local variables. We recommend using global variables, as local variables may not be supported in future versions. Local variables become obsolete once we have the SAV.Commands feature in place.

 

Following the prefix, the next 3 characters can be any combination of alphanumeric characters. A typical variable might look like '$$TXT' or '$$NUM.' At runtime, the variable is replaced with its internal content.

 

Using variables is straightforward:

 

- To set a variable as a string: 'VAS.$$TXT=Peter'

- To append to a variable: 'VAR.$$TXT+is a clown'

- You don't need quotation marks because of the fixed variable length: 'MBX.Hello $$TXT'

- End with 'ENR.'

 

You can also use variables for calculations:

 

- To use an integer variable: 'VIN.$$NUA=5'

- To use a floating-point variable: 'VFP.$$NUB=7.5'

 

Performing calculations with variables is as simple as:

 

'CAL.$$NUC=$$NUA+$$NUB'

'Result is 12'

'MBX.Result is $$NUC'

'ENR.'

 

When you use variables within variables or as parameters for subprograms, it becomes more complex. Consider this example:

 

' Variable Definition'

'VAR.$$TX1=5'

'Numeric Variable Definition'

'VAN.$$NUM=1'

'We generate a variable name inside $$IND'

'VAR.$$IND=$$TX$$NUM'

'This command is "Variable Indirect"; we assign to the variable name inside the variable.'

'VAI.$$IND=21'

'MBX.$$TX1'

'ENR.'

 

Internal variable resolution occurs in several ways:

 

- String variables are replaced.

- Numeric variables and formulas are solved.

- Special folders are replaced.

- System variables are replaced.

 

Not every command triggers variable resolution. This is because binary content may contain variable names or formulas that should not be resolved. Consequently, there are various variable resolution commands:

 

- VAB.: Does not resolve anything on the right side and is the fastest command.

- VAO.: Resolves just once, the first Variable it finds on the right side. Can also be used to delete  variable completely from Memory, if right side is empty.

- VAR.: Resolves System Variables and Special folders, and after that resolves normal Variables, this is the default option.

- VAS.: Resolves just like VAR. but adds one more Step of checking for System-Variables and Special folders after resolving the normal Variables. Use this command if you want to state that "this is a String-Variable".

- VAN.: Resolves normal Variables and checks for "(..)". If they are found the command tries to calculate a formula using "CAL." internally. The result will always be "Type 5 Floating Point Variable".

- VIN.: Resolves only the first Variable-Name it finds on the right side, if there is any. Will then try to interpret the result as a 64 Bit Integer Number. The result is always a "Type 4  64-Bit Integer Variable".

- VFP.: Resolves only the first Variable-Name it finds on the right side, if there is any. Will then try to interpret the result as a 80-Bit Extended Floating Point number. The result will always be "Type 5 Floating Point Variable".

           Faster then VAN. because it will not do any Calculation.

- VAI.: Assigns something to the variable, the name of which is inside the given variable. Useful in subprograms or macros for returning results in variables.

 

Variables also have a variable type internally, but in most cases, you won't need to deal with it.

You can use 'GVT.' to determine a variable's type and then decide how to handle its content.

Additionally, consider 'VBA.' as it can simplify working with unknown and Binary content.

 

 

Speed Considerations

 

You can speed up your Script if needed by using the right commands.

 

Mostly for scripts speed is not an issue.

However, if you have a script that should be as fast as possible, you can take this into account.

These variable commands, other than VAB., make a variable resolution on the right side.

This means they will look are there variables or special folders or system variables on the right side. And if so, they need to do extra steps. Extra steps cost extra time.

And that's why the speeds are not equal for all of these commands. So if you have only text or only numbers and no variables on the right side.

And there is nothing that should be calculated or whatever, you can have the fastest way to go using the VAB. command. If you have variables on the right side, like in part 2,

you can check if it is only one variable and it must only be one time resolved. Then VAO. is possibly the fastest solution.

Otherwise, it gets a bit slower because the Smart Package Robot will then resolve the first variable and then take the result and look if there are more variables inside after that one.

And he will do it depending on the command, for example with the VAV. command, as often as he finds new variables.

So even if the resolution of variables will lead to other variables, they will also be resolved with such a command like VAV.

However, you see that the VAV. command is, for example, three times as slow as the VAB. command for that reason.

VAO. is alternative to the normal VAR.-Command if you have just "one" Variable on the right side.

 

Text-Variable Assignment

 

clip0900

Speed Table for Assignment of Text to Variables

 

 

Numerical-Variable Assignment

 

clip0901

Speed Table for Assignment of numbers to Variables