Mathematical and algorithmic operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Mathematical and algorithmic operations >

Mathematical and algorithmic operations

IVN. / NVN. - If Variable Numeric

Previous Top Next


MiniRobotLanguage (MRL)

 

IVN./NVN. Conditional Statement

Test if Content of a Variable is numeric or not

 

 

Intention

 

Conditional Statement.

Test if a  Variable has numeric content or not. This Conditional Statement has 4 Options.

 

Mode 1:

IVN. in Mode 1 the Parameters get prefixed with a "#".
       Doing so, the IVN.uses a Simple character Compare. It will check if the Variable contains only allowed numerical characters, these are: "0123456789".

        In this mode IVN. will only accept pure decimal numeric numbers as valid.

        Sample:

 

$$TXA=099

IVN.#$$TXA

  MBX.Its numeric!

ELS.

  MBX.Its Not numeric!

EIF.

ENR.

 

Using

$$TXA=#099

IVN.$$TXA

 

will not work as the # is part of the Command. Otherwise it would compromise the commands safety.

 

Mode 2:

IVN. in Mode 1 the Parameters get prefixed with a "@".
       Doing so, the IVN.uses a Simple character Compare. It will check if the Variable contains only allowed numerical characters, these are: "0123456789.".

        In this mode IVN. will only accept pure decimal numeric numbers as valid.

        Sample:

 

$$TXA=0.099

IVN.@$$TXA

  MBX.Its numeric!

ELS.

  MBX.Its Not numeric!

EIF.

ENR.

 

Using

$$TXA=#1.099

IVN.$$TXA

 

will not work as the @ is part of the Command. Otherwise it would compromise the commands safety.

 

Mode 3:

IVN. in Mode 1 the Parameters get prefixed with a "*".
       Doing so, the IVN.uses a Simple character Compare. It will check if the Variable contains only allowed numerical characters, these are: "0123456789." and you can prefix the number with + or -.

        In this mode IVN. will only accept pure decimal numeric numbers as valid.

        Sample:

 

$$TXA=*-0.99

IVN.*$$TXA

  MBX.Its numeric!

ELS.

  MBX.Its Not numeric!

EIF.

ENR.

 

Using

$$TXA=*+19.099

IVN.$$TXA

 

will not work as the * is part of the Command. Otherwise it would compromise the commands safety.

 

 

Mode 4: Tolerance Mode - interpret as number.

IFC. in Mode 4, you do not use any Prefix. In this Mode the Robot will try to interpret the variable content as a number.

In this mode all sorts of numbers, Floating Point, Hexadecinmal, Octal, Binary ... and even Formulas in (..) will be recognized.

 

$$TXA=&H09A9

IVN.$$TXA

  MBX.Its numeric!

ELS.

  MBX.Its Not numeric!

EIF.

ENR.

 

 

' Floating Point Number
$$TXA=1.1E09

IVN.$$TXA

 

' Hexadecimal Numbers prefixed with "&H"
$$TXA=&H3A9

IVN.$$TXA

 

' Octal Numbers prefixed with "&O"
$$TXA=&O371

IVN.$$TXA

 

' Binary Numbers prefixed with "&B"

$$TXA=&B1011

IVN.$$TXA

 

' Even Formulas can be used:

$$TXA=(&H9+&O2)

IVN.$$TXA

  MBX.Its numeric!

ELS.

  MBX.Its Not numeric!

EIF.

DMP.6

MBX.$tos$

ENR.

 

 

In both modes, you will find the internally calculated "Match-value" on TOS.

This is the TOS after the Script above.
 

clip0094

You will find the resulting Number on TOS.

 

clip0093

    If no number was found you will find "Not Numeric" on TOS.

 

Speed-Consideration:

 

clip0096

 

IVN. and NVN are really fast and use only 54 to 170 Ticks to execute. Therefore you can execute >250.000 of these commands in one second.

 

NVN. is the negative Form of this statement.

 

 

 

Syntax

 

 

IVN.[#/@/*]P1 … ELS. … EIF.

NVN.[#/@/*]P1 … ELS. … EIF.

 

 

Parameter Explanation

 

# - optional Prefix If this Prefix is used then the Content of the Variable will only be checked against "0123456789". The condition will evaluate false if any other characters are inside the variable.

@ - optional Prefix If this Prefix is used then the Content of the Variable will only be checked against "0123456789.". The condition will evaluate false if any other characters are inside the variable.

* - optional Prefix If this Prefix is used then the Content of the Variable will only be checked against "0123456789." and Prefix of + and - will be allowed.. The condition will evaluate false if any other characters are inside the variable.

 

P1 - Variable to check if its numeric.

 

After the Operation you will find the numeric value on TOS. If no value could be found, you will find "Not Numeric." on TOS.

 

Please note that a leading "#","@" or "*" inside the Variable will not be interpreted as a Prefix but will lead to the result being "not numerical" as it should be.

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

 

 

 

 

Example

 

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

' IVN.-Test

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

FOR.$$PAA|-5|5|.125

  IVN.$$PAA

    GSB.Check_Val|$$PAA

  ELS.

    GTO.Lab_failed

  EIF.

NEX.

ENR.

' Prüft Value auf TOS gegen Angabe

:Check_Val

SAV.Save|$$SEB

VAV.$$SEB=§§_01

POP.$$SEA

PRT.$$SEB-"$$SEA"

JIS.$$SEA!$$SEB|Lab_failed

SAV.Restore

RET.

 

 

 

 

 

Remarks

-

 

 

Limitations:

 

-

 

 

See also:

 

    1.6.1. Program Flow Control

    1.5. Features and Hints

    FZC. - Fuzzy Compare

    IVP./ NVP. - If-Variable-Pattern

    IVC. / NVC. - If-Variable-Contains

    ELS. - ELSE

    EIF. - END IF

    CAL. - mathematical CALculation

    IVV. / NVV. - If Variable Value