|
<< Click to Display Table of Contents >> Navigation: 2. Components > 1. PreProcessor & EXE-Compiler > 1. PreProcessor |
Preprocessor-Directives
Smart Package Robot 's PreProcessor
The Preprocessor is the first Step in Script Execution. During this step, the Code will be changed by certain rules, before any other execution is done.

Smart Package Robot 's unique Preprocessor offers features like:
• define your own commands (MACRO's)
• The Preprocessor will also read the INLINE-Data between VDA. - VDE. and bring them into a Form where the Script can be executed with maximum Speed.
• use parameters with your own commands
• return results from your own "Macros" inside variables
• Overload Macros using GVT. (get Variable Type)
• react on the number of Parameters given.
• use Macros inside Macros
• use SAV. and SAV.Restore to make all used Variables "Local".
• Use VBS and Powershell inside your Macro's. (See VBS. and PWS.)
• use unique-labels and variables in your MACRO's
• include your personal subprograms with just one line of code, before the script runs using #INC:
• Influence the script-code before its being executed
To enable these features, the preprocessor analyzes and changes the script immediately before script execution.
Therefore the Preprocessor is not really a part of script-execution, its rather a script preparation.
Below is a schematic diagram of the Script execution process.
As you can see, the Preprocessor takes its part as step number two.
The preprocessor touches the script before execution. Therefore the execution stage will get the script that has already gone through the preprocessor.
PreProcessor commands generally start with a "#", followed by three letters. Please do not intermix PreProcessor-commands with Compiler-Commands. Compiler Commands are executed during compilation, and when the script is unpacked on the target machine.
Compiler-Commands generally start with a ' (Comment-Sign) to prevent them from being executed.
Preprocessor commands start with a "#".
Compiler-Directives start with " '#".

The Preprocessor processes the Source Code and can remove Lines and expand Macros.
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
Sample-Macros see here: ! User-Macros
See also:
•1.1 #INC: - Pre-Processor File-Include
•1.2 #ONCE / # OEND - Multiple Include Protection
•1.4 #IF ... #EIF - Decisions in Macros