#include-once #include ; #INDEX# ======================================================================================================================= ; Title .........: DefineUDF ; AutoIt Version : 3.3.14.5 ; Language ......: English ; Author(s) .....: JockoDundee ; Description : Simple C-like #define macro substituion. Doesn't do hardly anything except the most basic - no function ; No public functions or variables - just put this UDF as an #include. ; =============================================================================================================================== If $CmdLine[$CmdLine[0]] <> "1-defined" Then _DefineUDF_define() Func _DefineUDF_define() Local $sFname=("_defined_"& @ScriptName) FileDelete($sFname) Local $sFile=FileRead(@Scriptname), $sMatch, $sReplace Local $sLines = StringSplit($sFile, @LF & "#define ",3) For $n=1 To Ubound($sLines)-1 $sMatch=_StringBetween($sLines[$n],""," ")[0] $sReplace=_StringBetween($sLines[$n]," ",@LF)[0] $sFile=StringReplace($sFile,$sMatch,$sReplace) Next FileWrite($sFname, $sFile) $sComm=StringReplace($CmdLineRaw, @ScriptName, "_defined_"& @ScriptName) Run(@AutoItExe &" "& $sComm &" 1-defined") Exit EndFunc