|
<< Click to Display Table of Contents >> Navigation: 2. Components > 1. PreProcessor & EXE-Compiler > 1. PreProcessor |
MiniRobotLanguage (MRL)
#VARD
Assign Variables a numerical Integer Value in the Preprocessor
Intention
You can use this preprocessor command to assign a numerical value in the long integer range to variables.
By default, the preprocessor uses variables in module 255, which means that these variables will not be visible to the robot at runtime unless you change the module range to module 255, which is the highest available module.
VAR.$$AAA=100
' TEse Vars are set at Preprocessiing time in MODULE Nr.255
#VARD $$AAA=(3+1)
#VARD $$AAB=($$AAA*4)
' We enter Module 255
MOD.Enter|255
MBX.$$AAB
' We return to the default Module (0)
MOD.Return
' We get the RUntime Value
MBX.$$AAA
DMP.Speed
MBX.!
ENR.
Here is the result you will get with the Script.


There is an Order of processing inside the Pre-Processor, the following Commands are processed sequentially:
1. #INC:
2. #LIB:
2. #ONCE / #OEND / #OREM
4. #VARD
5. #IFVA / #ELSA / # EIFA and #IFVL
6. #SCSA / #CASE / #CSEA / #ENSA
7. Macros etc.
8. Collecting Labels
This is important, because of this you can use the Preprocessor to remove Macro-Lines and Labels from the Code.
You can not use t to remove #INC: or #LIB: from the Code as its processed before, with highest Priority.
ts even processed before #ONCE: therefore #ONCE will not protect from these directives.
Generally the Priority of #ONCE ... #OEND is the highest.
Anything that is in there will be removed from the Code if the Condition s "Duplicate".
Of course the Directives themselves will also be removed from the final Code as well before Execution.
Generally Directives are processed and removed in one step.
In the next step the Compiler defines numerical Variables in Model-Space 255.
These Variables are available from that Moment and can be used inside #IFVA, #IFVL #SCSA, and wth #CASE .
For example like this:
#VARD $$VER=3
#IFVL $$VER>1
Here is a Real-Life Sample from the "Twitter-Button Bar" from Sample-Code Folder.
Using this System, we can remove Lines with Macros from the Code before the Script starts running.
#VARD $$VER=1
%SetText Letztes Diktat|Zuletzt diktierten Text wiederherstellen und einfügen.
#IFVL $$VER>1
%SetText UnDo|Letzte Textänderung im Arbeitsbereich rückgängig machen.
'-------
%SetText Schiller//Goethe|Zwischenablage-Text in Schillers oder Goethe's poetischem Stil neu interpretieren.
#IFVA $$VER>1
%SetText E. Roth//Sam Hawkins|Zwischenablage-Text im humorvollen Stil von Eugen Roth oder SAm Hawkins neu dichten.
%SetText W. Busch//Morgenstern|Zwischenablage-Text in Wilhelm Buschs oder Christian Morgenstern's satirischem Versmaß umwandeln.
%SetText Dichter//Erhard|Zwischenablage-Text im Stil eines wählbaren Dichters oder RMB: Heinz Erhardt's Stil neu interpretieren.
#EIFA
Important Implications:
This will also prevent the use for the "higher Constructs" (1.-6.) Inside Macros, because at the Time of Macro-Expansion, they simply do not exist anymore.
You can generally nest these Construction. Again there is a Priority that the most outer Construct will remove anything inside if the Condition is not "True".
It does not matter f a "inner Condition" is true or not, f the outer Condition is False.
' This the case where its removed from the Code
#VARD $$VER=3
#IFVA $$VER>3
#IFVA $$VER>1
.. Will be removed
#EIFA
#EIFA
' This the case where ts not removed
#VARD $$VER=3
#IFVA $$VER>2
#IFVA $$VER>1
.. Will not be removed
#EIFA
#EIFA
You also need to understand that the #SCSA are generally processed after the #IFVA and therefore have a general Priority.
However that seems to not be any problem, as it does not Matter when a Construct is removed. In cases like below, first the #IFVA are processed and in the next Pass the #SCSA are processed.
The result is the same.
#VARD $$VER=3
#SCSA $$VER
#CASE 1
#IFVA=3
... will be removed from the #SCSA
#EIFA
#CASE 2
#CSEA
#ENSA
Syntax
#VARD P1=P2
Parameter Explanation
P1 - Variable-Name like $$ABC
P2 - Value can be a numerical Value or a calculation in (). Can also be another numerical Variable that was defined before by the Preprocessor Command #VARD. Anything that does not evaluate to a Integer (32-bit) will be treated a "0".
Example
'***********************************
' #VARD -Sample
'***********************************
#VARD $$ABC=1999
#VARD $$ABC=-129
#VARD $$ABC=$$AFF
#VARD $$ABC=(1999*56)
#VARD $$ABC=($$ABB+1999*56)
Remarks
-
Limitations:
-
See also:
• ! Smart Package Robot 's Parallel Robot Operations