1. PreProcessor

<< Click to Display Table of Contents >>

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

1. PreProcessor

#INC: - Preprocessor-File Include  

Previous Top Next


Preprocessor-Directives

 

#INC:

Preprocessor File-Include

 

 

Intention

 

This Preprocessor-Directive will insert Code from a file  at the Place where it occurs.

It can occur many times in the Skript and can even be used recursively.

 

#INC: is a preprocessor command, to include code-lines or complete files into your Scripts.
These can be your personal MACROS or variable definitions into your script. The inclusion of the file will be done immediately and on the lowest level.

The rest of the script will not see any difference between, if the file was included or if it had been pasted. It will be like the file plus the inclusions is one large file.

 

Normally, if you want to call a "SubScript" you would call JNF. at runtime. In that case you can use system local variables and the systen local stack. #INC is very different from that. It just mixes the the files into one file before they really get processed.

 

Assume that you have several MACRO packages that you want to load into your script, using #INC:. You can even nest as many #INC:'s to unlimited depth on your own risk.

 

What if each of the packages calls a main-package with your own, general definition?

How can you prevent, that a file with Macro-Definition (or any other) is included several times?

 

This can be done unsing the #ONCE ... #OEND Option. This way you can be sure that any package with definition is just loaded once.

 

If you want to run your files as compiled Stand-Alone executable, make sure that all needed scriptfiles are being included into the executable package. For this you will need the compile-time command '#INC:. It looks similar but is something else!

 

Important note:

Do not intermix the Preprocessor-File-Include #INC: with the Compile time command '#INC:. The later will include files int othe executable package. While looking similar, these are two very different animal. The difference is the small " ' " comment operator. If its missing, we have the preprocessor-file include. If the comment-sign is there, its a compile.time command!

 

To learn more about the compile time command '#INC: see

2.1.8 '#INC: - Include Files and Folders into the Executable

 

Hint: Use this command together with the 2.1.A #LIB: - User-Library Path command. You can #INC: directly from the User-Library.

       Also note that all ".mrt"-files that are included with the #INC: directive can be encrypted using the '#CRY: - directive.

 

 

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:

 

#INC:P1

 

P1 - Filename including path to the file. If you want to run the script as Standalone "EXE" File, you should copy the file to the project folder, that is the folder where the script itself is.

 

 

Example:

 

For this example we need two files.The Main file, we want to execute/compile. And the Macro file that we want to include.

 

' Main-File

 

DBM.1

#INC:Macros.mrt

: §§VAL=5

' Here we check only the lower bound

%Check_Bounds §§VAL|6

PRT. First Result is §§VAL

MBX. Ready

ENR.

 

 

' This is the additional file,

' which is included.

'

' The Macro checks parameter 1 against

' parameter 2 as Lower Bound.

' if parameter 3 is available, parameter 1 will be

' checked against parameter 3 as upper bound

'

: %Check_Bounds 2

IVV.§§§01<§§§02

 : §§§01=§§§02

EIF.

#IF PARAMS>2

IVV.§§§01>§§§03

 : §§§01=§§§03

EIF.

#ELS

PRT.Nur ein Parameter

#EIF

PRT.Hallo

END%

 

 

 

Remarks:

 

All Commands starting with a "#" are Preprocessing Commands. These commands are used by the built-in preprocessor to change the code before execution.

These commands will not be available in the code at runtime. These commands have no access to Variables and Runtime Resources. These commands will influence the code before it is actually starting.

When compiling an executable, the editor tries to include the filename after #INC: automatically into the package. If no path is given, "?path\" is assumed to be the location of the script file. Therefore its best practice to have the include-files in the same folder as the Main script file.

 

 

Limitations:

-

 

 

See also:

 

  : - MACRO-Definitions

#ONCE / # OEND

  2.1.A #LIB: - User-Library Path

2.1.8 '#INC: - Include Files and Folders into the Executable

! Smarty's Preprocessor

1.1 #INC: - Pre-Processor File-Include

1.2 #ONCE / # OEND - Multiple Include Protection

1.8 : - MACRO-Definitions

1.4 #IF ... #EIF - Decisions in Macros