trap16 Posted March 4, 2010 Share Posted March 4, 2010 (edited) Hello, I looked in help file but did not find any way to use an equivalent to C Macro #define keyword This is an (useless) example i would like to insert in autoit script : #define myMacro(x,y) ((x < 10 and y < 10)) If myMacro($a,$c) Then ; do process Endif Best regards. Edited March 4, 2010 by trap16 Link to comment Share on other sites More sharing options...
jchd Posted March 4, 2010 Share Posted March 4, 2010 No such construct exists in AutoIt, only actual functions. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Fulano Posted March 4, 2010 Share Posted March 4, 2010 You could implement something like that by making a script that defines your macros and run it on your source code to convert your shortcuts into code. Probably wouldn't make sense though, as that sort of overhead only really makes sense with a compiled language. #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 4, 2010 Share Posted March 4, 2010 I looked in help file but did not find any way to use an equivalent to C Macro #define keyword You would use a function. Here's an example: Local $iA = 7, $iC = 5 If _myFunction($iA, $iC) Then MsgBox(0, "Shut up while i'm talking", "The numbers seem to be smaller than 10") EndIf Func _myFunction($iX, $iY) If $iX < 10 And $iY < 10 Then Return True EndFunc .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 4, 2010 Share Posted March 4, 2010 You would use a function. Here's an example: Local $iA = 7, $iC = 5 If _myFunction($iA, $iC) Then MsgBox(0, "Shut up while i'm talking", "The numbers seem to be smaller than 10") EndIf Func _myFunction($iX, $iY) If $iX < 10 And $iY < 10 Then Return True EndFunc That made me sad Alkex. You have no return value if either number is larger than 10. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 4, 2010 Share Posted March 4, 2010 (edited) That made me sad Alkex. You have no return value if either number is larger than 10.There's no need for that since functions by default return 0, and 0 is usually returned when things go wrong in AutoIt.Edit: And it was meant as an example based on trap's code, not a fullblown UDF meant for official inclusion in AutoIt (strange grammar?). Edited March 4, 2010 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
jchd Posted March 4, 2010 Share Posted March 4, 2010 Alkex, make Richard's day sunny again with even simpler code, as both of you know: Func _myFunction($iX, $iY) Return(($iX < 10) And ($iY < 10)) EndFunc This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 4, 2010 Share Posted March 4, 2010 I think Richard wanted the opposite. Func _IsNumberOver10($iX, $iY) If (Not IsNumber($iX)) Then Return SetError(2, 0, False) If (Not IsNumber($iY)) Then Return SetError(3, 0, False) If $iX < 10 And $iY < 10 Then Return True Return SetError(1, 0, False) EndFunc .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
trap16 Posted March 6, 2010 Author Share Posted March 6, 2010 Thanks for the information. Best regards. Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 6, 2010 Share Posted March 6, 2010 I think Richard wanted the opposite. Func _IsNumberOver10($iX, $iY) If (Not IsNumber($iX)) Then Return SetError(2, 0, False) If (Not IsNumber($iY)) Then Return SetError(3, 0, False) If $iX < 10 And $iY < 10 Then Return True Return SetError(1, 0, False) EndFunc Yes perfect. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now