<< Click to Display Table of Contents >> Navigation: 3. Script Language > SCS. - Select from Mutiple Cases > Multiple Choice Commands |
MiniRobotLanguage (MRL)
CAN. Command
Case Numeric
Intention
This command can be used to script multiple-choice decisions ("SELECT CASE") using a numerical choice.
Mostly it will be used with SCN. as its for numerical choices.
It has to be used together with:
SCN., or SCS.
and
CAS.,CAE., and ESC..
This Command can be used Single Choice:
CAN.2
and also supports the use of "," and multiple choices like:
CAN.2,3,($$NAT+1),$$PIS,8
See example below.
$$NUM=3
GSB.decide
$$NUM=7
GSB.decide
$$NUM=4
GSB.decide
ENR.
'---------------------
:decide
SCN.$$NUM
CAN.2,3,($$NAT+1),$$PIS,8
DBP.I am here with 2
CAN.(2+1)
DBP.I am here with 3
CAN.4
DBP.I am here with 4
CAE.
DBP. Anything else
ESC.
RET.
It will also work with Floating Point numbers:
$$NUM=6.012
SCN.$$NUM
CAN.6
DBP.I am here with 2
CAN.(5+1)
DBP.I am here with 3
CAN.(6+0.012)
DBP.I am here with 6.012
CAE.
DBP. Anything else
ESC.
ENR.
Syntax
CAN.P1
Parameter Explanation
P1 - Numeric value or variable which shall be compared to the SCS./SCN.-Parameter. Can use Formula in Brakets like: ($$NUM*$$EXP+($$REZ))
which is evaluated at runtime. Actually the result is compared to the Parameter from SCS. or SCN.
CAN. and also supports the use of "," and multiple choices like:
CAN.2,3.534,($$NAT+1),$$PIS,8.3
Supports Floating-Point or Integer Numeric types and Formulas in "(...)".
Speed in Ticks:
This command uses typically around 18(fixed number as Parameter) to 130 Ticks (Variable as Parameter). If you use difficult Formula, even more.
Example
'********************************************
' Demo for SCS., CAS., CAE., ESC. and CAN.
'********************************************
' SCS.-Test
'DBM.2
'-----------------------------------------------------------
FOR.$$LOP|1|20
VAR.$$TXT=Peter$$LOP
VAR.$$NUM=500
PRT.TXT=$$TXT
SCS.$$TXT
CAS.Was first case.
PRT.First Case
' This one will come in the twentieth
CAS.{Rufus&OR:Peter2}
PRT.Was "Peter2..."
' You can jump out of the structure directly with GOTO.
' And you can nest unlimited many SCS.
SCS.$$NUM
CAN.(100*5)
PRT.You can nest it unlimited.
CAN. 499
' You can even intermix CAS. / CAN.
CAS. Intermixed
CAE.
PRT.THis will not come
ESC.
JMP. otu
CAS.Third
PRT.Was Third
CAS.{Peter&AND:3}
PRT.Was "Peter" and "3"
' If you need a perfect match ...
CAS.{&EXACT:Theo}
PRT.This one is Theo.
CAS.Fourth.
PRT.Was this one.
' CASE ELSE
CAE.
PRT.Was nothing of all.
' END SELECT
ESC.
:otu
NEX.
MBX.Ending
:enz
END.
Remarks
please do not write code between the SCS. and the first following CAS./CAN.
While this code will actually be executed, you could get memory-leaks if you jump out of the construct from that place.
Limitations:
There are no relevant nesting limitations.Please always make formulas into () or they may not be calculated.
See also: