Variable Commands

<< Click to Display Table of Contents >>

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

Variable Commands

IVC. / NVC. - If-Variable-Contains

Previous Top Next


MiniRobotLanguage (MRL)

 

IVC./NVC. Conditional Statement

If Variable Contains

 

 

Intention

 

Conditional Statement. Test if a specified text or binary string  is contained in a given variable/text. The first parameter must be a variable.

 

There are several special operators and the 2 options "e - equalcase" and "b - binary".

Let us start with a simple example. We want to compile a script and make it react on a commandline parameter.

 

' Get the commandline

VAR.$$CMD=$cmdexe$

IVC.$$CMD=/u

 MBX.We'll uninstall it!

EIF.

ENR.

 

Now in case that we want to react on /u as well as on /U, we would need to specify the "e" option, that prevents the command from being case-sensitive. We would just change this line to get the desired effect:

 

IVC.$$CMD=/u|e

 

Now if you look for some special parameter in the command-line, you also want to know where it has been found. The position in the string, where the "/u" was. You get it from IVC. on the TOS.

 

VAR.$$CMD=/c:file.txt /U:mix.log

IVC.$$CMD=/u|e

 STS.DUMP

 MBX.!

EIF.

ENR.

 

The result will look like this, because the /u starts at character 13:

 

graphic

 

There is more. Assume that you want to know if a text contains ANY of a list of special characters. Going from here you would need to check for each single character. But help is here! You can use the <  (ANY OF) Operator.

 

 

VAR.$$NAM=Rolf Müller

IVC.$$NAM<üäö

 DBP. german Umlaut found at $$000!

EIF.

ENR.

 

But do not intermix it with the > "ONLY ANY OF" Operator. This one will make sure that the given string contains ONLY characters that are are contained in the text/string given.

 

VAR.$$NAM=Rolfi

IVC.$$NAM>folR

 DBP. Its Ok!

ELS.

 DBP. Non matchin character found at $$000!

EIF.

ENR.

 

Which is not the case here. Therefore we get:

 

graphic

 

There is one more option to know, that is the "binary" option. When you want to find a string in a binary file, you must prevent the robot from searching for variables and special folders etc. in the binary code. The variable with the binary code must be resolved - and that is all.

This is done using the b - flag. Binary data is often read from files, maybe to patch them.

IVC. can help you on this. Here is an example for the usage of the b-option.

 

CFF.$$FIL|$$BIN

IVC.$$BIN=$$PAT

  ' do the patch

 STS.DUMP

 MBX.!

EIF.

ENR.

 

Hint: If you think that the evaluation is not correct, use

 
PRT.$$VAR|h

MBX.!

 

to check for invisible characters and Spaces. You will get a ASC-Dump like this, which shows all characters inside the variable with their Hex-ASC-Code.:

 

ASC-Dump

 

 

The negative Form NVC. is also available.

 

 

 

Syntax

 

 

IVC.P1P2[|P3]… ELS. … EIF.

NVC.P1P2[|P3]… ELS. … EIF.

 

 

Parameter Explanation

 

P1  - Variable[Operator]

 

=  "contains" - the whole string must be contained in variable.

   TOS is position in variable.

 

!  "contains not" - just the opposite of "=".TOS is position

   in variable.

 

>   contains "only any of". Must contain only each

   of the given characters. TOS is first non matching character.

 

<   "contain any". Is true if any of the given characters is

   containes in variable. TOS is position of first match.

 

e   equalcase. The compare etc. will be done after all characters

   have been converted to ANSI-Lower-case.

 

b   binary. In this case the Variables are only resolved once,

   specialfolders etc. are not resolved.

 

 

P2 - Variable, contains the text/string with the characters

    to look for.

 

P3  - (optional) can be b - binary or e - equalcase.

 

 

 

IVC.'s can be nested to unlimited Depth, and they can also enclose Sub-Programm Calls or  FEX. (Enumerations) to unlimited Depth.

 

 

Speed in Ticks:

This command uses typically around 130 to 250 Ticks heavily depending on Parameters.

 

 

Example

 

'***********************************

' GFS.-Test

'***********************************

'DBM.2

'JNF.Move-Console.txt

 

: $$TXT=12345678Abcde

: §§NUM=456

 

' This is a "Contains"

IVC.$$TXT=§§NUM

PRT. §§NUM is a part of $$TXT

ELS.

PRT. §§NUM is NOT part of $$TXT

EIF.

' Stack contains place where it was found.

DMP.4

 

' This is a "NOT Contains"

IVC.$$TXT!§§NUM

PRT. §§NUM is not a part of $$TXT

ELS.

PRT.§§NUM is a part of $$TXT

EIF.

' Stack contains place where it was found.

DMP.4

 

 

' This is a "Contains ANY"

IVC.$$TXT<152

PRT. $$TXT contains any of: 125

ELS.

PRT. $$TXT contains none of: 125

EIF.

' Stack contains place where it was found.

DMP.4

 

 

' This is a "NOT Contains ANY"

IVC.$$TXT>5a6

PRT. $$TXT contains all of: 5a6

ELS.

PRT. $$TXT contains not all of of: 5a6

EIF.

' Stack contains the position of the first non-matching character.

DMP.4

 

DMP.

END.

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also:

 

    1.5. Features and Hints

    IWS. / NWS. - If Window State

    IVC. / NVC. - If-Variable-Contains

    IVV. / NVV. - If Variable Value

    ELS. - ELSE

    EIF. - END IF

    CAL. - mathematical CALculation