Variable Commands

<< Click to Display Table of Contents >>

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

Variable Commands

IVB. / NVB. - If Variable Between

Previous Top Next


MiniRobotLanguage (MRL)

 

IVB. Conditional Statement

If Variable Between

 

Intention

 

Conditional Statement.

Test if a specified numeric variable or point-variable is between the two given limits P2 and P3. Let's see an example:

 

' Here we define the value that is tested

' and the minimum and maximum value

VAR.$$ERT=15.05

VAR.$$MIN=15.06

VAR.$$MAX=16.001

' Here comes the test

IVB.$$ERT|$$MIN|$$MAX

 DBP.We're between

ELS.

 DBP. We're outside

EIF.

 

As expected, the result is:

 

graphic

 

If we change the line:

 

VAR.$$MIN=15.04

 

we get the result like this:

 

graphic

 

Now lets see how it works with point-variables. Imagine you want to make sure that coordinates stay in a specified range. Its always an x and  an y - coordinate.

 

VAP.$$ERT=55,30

VAP.$$MIN=0,0

VAP.$$MAX=45,40

IVB.$$ERT|$$MIN|$$MAX

 DBP.We're between

ELS.

 DBP. We're outside

EIF.

 

As the x-value is 55 and therefore exceeds the given range of 45, we're outside this time.

What happens is, that the instruction will test that the x and the y value are in their range that is given with the two range-points.

 

 

 

In case of numeric variables, P2 and P3 can be any numeric variables with about 80 bits of precision.

 

In case of point-variables, P2 and P3 must be Points also

 

 

 

Syntax

 

IVB.P1|P2|P3 ELS. … EIF.

 

 

Parameter Explanation

 

P1 - Variable or Point Variable with value(s) to test

 

P2 - minimum value

 

P3  - maximum value(s)

 

 

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

 

 

 

Example

 

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

' IVB./EVB.-Sample

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

'------------------------------------------

: §§LLV=0

: §§ULV=1

: §§TVA=.5

IVB.§§TVA,§§LLV,§§ULV

§§ERG=1

ELS.

§§ERG=0

EIF.

MBX.$$ERG

'------------------------------------------

: §§LLV=0

: §§ULV=1

: §§TVA=.5

NVB.§§TVA,§§LLV,§§ULV

§§ERG=0

ELS.

§§ERG=1

EIF.

'------------------------------------------

: §§LLV=-5,-4

: §§ULV=5,6

: §§TVA=0,0

NVB.§§TVA,§§LLV,§§ULV

§§ERG=0

ELS.

§§ERG=1

EIF.

MBX.$$ERG

'------------------------------------------

: §§LLV=-5,-99

: §§ULV=5,0

: §§TVA=0,1

IVB.§§TVA,§§LLV,§§ULV

§§ERG=0

ELS.

§§ERG=1

EIF.

MBX.$$ERG

END.

 

' Using Point Variables

VAP.$$ERT=55,30

VAP.$$MIN=0,0

VAP.$$MAX=55,10

IVB.$$ERT|$$MIN|$$MAX

 DBP.We're between

ELS.

 DBP. We're outside

EIF.

ENR.

 

 

Remarks

 

-

 

Limitations:

 

-

 

 

See also:

 

    1.6.1. Program Flow Control

    ELS. - ELSE

    EIF. - END IF