Skip to content

Simple Präprozessor

Thorsten Willert edited this page Jan 6, 2020 · 2 revisions

PP Simple preprocessor:

(would be replaced by FreeMarker / FMPP)

Statements and constants
#define Definition of simple macros
#undefine / #undef removs a macro
#ifdef / #elif / #else / #endif Conditional statement (not nestable yet)
__TIME__ Replaced with the current time
__DATE__ Replaced with the current date
__DATE_AND_TIME__ Replaced with the current date and time
__NAME__ Replaced with full filename
__FILE__ Replaced with filename
__AUTOIT_VERSION__ Replaced with the version number of AutoIt
__AUTOIT_BETAVERSION__ Replaced with the beta-version number of AutoIt

Replaces:

var++	var += 1
var--	var -= 1
var=(a?b:c)	If a Then var=b Else var=c
a?b:c	If a Then b Else c
a<<b	BitShift(a, b)
a>>b	BitShift(a, -(b))
~a	BitNot(a)
!a	Not a
!(	Not (...
a % b	Mod(a, b)
a <<= b	a = BitShift(a, b)
a >>= b	a = BitShift(a, -(b))
a %= b	a = Mod(a, b)
For $i : $Array	For $i = 0 To UBound($Array)-1

Input e.g.:

; File ............: __NAME__
; AutoItVersion ...: __AUTOIT_VERSION__
; Time ............: __TIME__
; Date ............: __DATE__

#define Text "foo bar"
#define Var1 $ok[$i]
#define Var2 $test
#define Beta

~$b[$i]
$a %= $b
$a <<= $v[$i]
$a >>= $v

#ifdef Beta
        #include <test_beta.au3>
#else
        #include <test.au3>
#endif


Var1 = ( 1 > $a ? "ok" : Text )

For $i : $aArray
        MsgBox(64,"",$aArray[$i])
Next

#undef Var2

#ifdef Var2
        MsgBox(64,"","1")
#elif Test
        MsgBox(64,"",Var2)
#elif Var1
        MsgBox(64,"",Text)
#else
        MsgBox(64,"","3")
#endif

Output: (after tidy)

; File ............: pp_test.au3
; AutoItVersion ...: v3.3.0.0
; Time ............: 20:20:35
; Date ............: Mi Mai 2009

BitNOT($b[$i])
$a = Mod($a, $b)
$a = BitShift($a, $v[$i])
$a = BitShift($a, -($v))

#include <test_beta.au3>

If 1 > $a Then
        $ok[$i] = "ok"
Else
        $ok[$i] = "foo bar"
EndIf

For $i = 0 To UBound($aArray) -1
        MsgBox(64, "", $aArray[$i])
Next

MsgBox(64, "", "foo bar")
Clone this wiki locally