1. PreProcessor

<< Click to Display Table of Contents >>

Navigation:  2. Components > 1. PreProcessor & EXE-Compiler >

1. PreProcessor

1.6 #IFVA / #ELSA / #EIFA / #IFVL- Conditional Compile/Remove Lines from Code

Previous Top Next


MiniRobotLanguage (MRL)

 

#IFVA / #ELSA / #EIFA / #IFVL

Conditional Compile/Remove Lines from Code

 

 

Intention

 

This is a conditional statement that is evaluated during the preprocessing time.

This collection of commands are conditional statements that are evaluated during the processor runtime. These commands can evaluate either numbers or variables or expressions in brackets.

Using these Preprocessor-commands you can decide during the preprocessing Time which code should be included in the final runtime and which lines should be removed, with a conditional statement.

 

This command can only access variables that have been defined with the VARD processor command, as all other variables are not yet defined at this point. These variables are also available later at runtime, but in module space 255.

This means that the Preprocessor variables are initially separated from the normal runtime variables, which are in module space 0, but are still available if you switch to Module-Space 255.

 

You can use multiple values that will all be checked, if any of these evaluates to True, the condition is true.

#VARD $$AAA=1

#VARD $$AAB=4

' Use multiple values with #IFVA separated by ","

#IFVA ($$AAB<0),0,1,0

DBP.OK

#EIFA

 

This Command can be nested to a depth of 512 nesting Levels.

 

The #IFVA / #IFVL - Commands are evaluated in the Pre-processor after the #ONCE Commands, and therefore have a lower Priority.

 

#VARD $$AAA=0

 

#IFVA $$AAA

DBP.OK

#ELSA

DBP.No

#EIFA

 

#IFVA 0

#IFVA 1

DBP.OK-X

#ELSA

DBP.No-X

#EIFA

#ELSA

DBP.No-Y

#EIFA

 

' This COmmand will only remove the mmediiately following Line

#IFVL 1

DBP.Hallo A

DBP.Hallo B

 

#IFVA 0

#IFVL 1

DBP.Hallo AA

DBP.Hallo BB

#ELSA

DBP.Hallo DD

#EIFA

 

DMP.Speed   

MBX.!

ENR.

 

clip1059

 This is the Result from the above Code.

 

 

Order of Processing in the Pre-Processor:

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

 

 

#IFVA.P1,[Px...]

#ELSA

#EIFA

 

#IFVL P1,[Px...]

 

 

Parameter Explanation

 

P1 - 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".

        Any value that is not "0" will evaluate to "True" and make the condition to be "True".

          Can contain multiple Elements separated by comma, if any of these elements evaluates to "True" the condition is true.

 

 

 

Example

 

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

' #IFVA-Sample

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

' These Vars are set at Preprocessiing time in MODULE Nr.255

#VARD $$AAA=0

 

#IFVA $$AAA

DBP.OK

#ELSA

DBP.No

#EIFA

 

#IFVA 0

#IFVA 1

DBP.OK-X

#ELSA

DBP.No-X

#EIFA

#ELSA

DBP.No-Y

#EIFA

 

DMP.Speed   

MBX.!

ENR.

 

 

 

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also: