So I'm thinking about creating a preprocessor for AutoIt and was wondering on whether you had any ideas?
Thanks.
Quick idea:
Thanks.
Quick idea:
[ autoit ]
#include <Array.au3> #include <Constants.au3> #define MSGOK = 4096 #define MATCHSTRING = "This is some simple string" & @CRLF #define PI = 3.14159 Local $sScriptFileData = 'MsgBox(#MSGOK, "", "")' & @CRLF & @CRLF & 'StringInStr("Some string example",#MATCHSTRING, "#PI") ; #PI shouldn''t be expanded in strings.' Local Const $aMacros = PreProcessorMacros(@ScriptFullPath) ;~ _ArrayDisplay($aMacros) For $i = 1 To $aMacros[0][0] $sScriptFileData = StringRegExpReplace($sScriptFileData, '#\b' & $aMacros[$i][0] & '\b', $aMacros[$i][1]) Next MsgBox($MB_SYSTEMMODAL, '', $sScriptFileData) Func PreProcessorMacros($sFilePath) Local $aMacros = StringRegExp('#define macrocount = 0' & @CRLF & FileRead($sFilePath), '(?im:^#define\h+)(\w+)(?:\h+=\h+)([^\r\n]+)', 3) $aMacros[0] = UBound($aMacros) - 1 Local $aReturn[($aMacros[0] / 2) + 1][2] = [[0]] For $i = 2 To $aMacros[0] Step 2 $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0] = $aMacros[$i] $aReturn[$aReturn[0][0]][1] = $aMacros[$i + 1] Next Return SetError($aReturn[0][0] = 0, 0, $aReturn) EndFunc ;==>PreProcessorMacros