Variable Commands

<< Click to Display Table of Contents >>

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

Variable Commands

GVT. - Get Variable Type

Previous Top Next


MiniRobotLanguage (MRL)

 

GVT. Command

Get Variable Type

 

 

Intention

 

This command can be used to find out which Vartype was used for the given Variable In P1. There are generally 8 Types of variables that are available for Scripting (Type 7 should never happen):

 

1 = Stringvariable (ASC-Text or Data)

2 = LongInteger (32 - bit signed Number)

3 = PointAPI (2 Integer Coordinates, e.g. X and Y)

4 = Quad (64 Bit Signed Integer)

5 = Extended Precission Floating Point Number

6 = Rect 

7 = unknown Stringtype

8 = Empty string / Variable invalid and can not be resolved.   

 

' Example:

 

' Here we define some Variables

' Extended FP Variable (Type 5)

VAN.$$ERT=15.05

 

' String Variable - (Type 1)

VAR.$$RTT=A

 

' Extended FP Variable (Type 5)

VAN.§§XTT=0.015

 

' Point-API Variable (Type 3)

VAP.$$MYP=12,13

 

GVT.$$ERT

DBP.$tos$

 

GVT.$$RTT|$$RES

DBP.$$RES

 

GVT.§§XTT|$$RES

DBP.$$RES

 

GVT.$$MYP|$$RES

DBP.$$RES

 

' This variable is undefined you will get a

' result zero, and the timeout flag will be set.

'

GVT.$$MYP|$$RES

DBP.$$RES

 

ENR.

 

Note that currently Variables will normally loose their Variable-Type (and get Type 1 String)  if they are assigned to another Variable. You can avoid this by using the VAO.-Command:

 

' This will preserve the Variable Type

VAO.$$ABC=$$EFG

VAO.$$ABC=§§_01

 

 

 

Syntax

 

GVT.P1[|P2]

 

 

Parameter Explanation

 

P1 - Variable-name of Source and Target variable

 

P2 - (optional) Variable which will receive the result. If

    omitted the result is placed on TOS.

 

 

Example

 

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

' GVT.-Sample

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

VAN.$$PAA=5.56

VAN.$$PAB=7

GSB.Add|$$PAA|$$PAB

MBX.Result is: $$RES

 

VAR.$$PAA=Max

VAR.$$PAB=Müller

GSB.Add|$$PAA|$$PAB

MBX.Result is: $$RES

 

END.

:Add
' We use VAO. to preserve the Variable Type

VAO.$$TGA=§§_01

GVT.$$TGA|§§TYP

DBP. Vartype is §§TYP.

CAL.§§TYA=(§§TYP=2)+(§§TYP=4)+(§§TYP=5)

IVV.§§TYP=1

  $$RES=$$PAA,$$PAB

EIF.

IVV.§§TYA=1

  CAL.$$RES=$$PAA+$$PAB

EIF.

RET.

ENR.

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

 

 

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

' GVT.-Sample 2

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

VAN.$$PAA=5.56

VAN.$$PAB=7

VAO.$$REA

%Add $$PAA|$$PAB|$$REA

MBX.Result is: $$REA

 

VAR.$$PAA=Max

VAR.$$PAB=Müller

VAO.$$REA

%Add $$PAA|$$PAB|$$REA

MBX.Result is: $$REA

END.

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

: %Add 3

GSB.Add|§§§01|§§§02|§§§03

END%

 

:Add

SAV.Save|$$ERG|$$TGA|$$TYP|$$PAA|$$PAB

VAR.$$PAA=§§_01

VAR.$$PAB=§§_02

VAO.$$ERG=§§_03

DBP.ERG=$$ERG

VAO.$$TGA=§§_01

GVT.$$TGA|$$TYP

DBP. Vartype is $$TYP.

CAL.$$TYA=($$TYP=2)+($$TYP=4)+($$TYP=5)

IVV.$$TYP=1

  $$RES=$$PAA,$$PAB

EIF.

IVV.$$TYA=1

  CAL.$$RES=$$PAA+$$PAB

EIF.

VAI.$$ERG=$$RES

SAV.Restore

RET.

 

ENR.

'===========================================================

 

 

 

Remarks

 

-

 

 

Limitations:

 

Note that currently Variables will normally loose their Variable-Type (and get Type 1 String)  if they are assigned to another Variable. You can avoid this by using the VAO.-Command:

 

' This will preserve the Variable Type

VAO.$$ABC=$$EFG
 
The overall maximum length of variables depend on your available RAM and your actual Memory fragmentation. String memory needs to be in one piece and can not be fragmented. As a raw assumption, 500 MB maximum size for strings should always be possible. If you stay below you should be on the safe side. The theoretical maximum is about ~2 GB.

 

 

 

See also:

 

    VAB. - Variable Binary

    VAC. - Variable reCt

    VAN. - Variable Numeric

    VAO. - Variable Once

    VAP: - Variable Point

    VAR. - Variable Set Value/Clear

    VAS. - Variable with String

    VAV. - Variables with Variables

    VBA. - Variable Binary Append

    CAL. - mathematical CALculation

    2.1 : - Definiton-Command