delme 0 Posted May 10, 2010 (edited) Hey guys, I'm coding an irc bot that will have plugin funtionality, ie: it will call certain functions when events happen, it will work something like this: A message is recieved, bot checks for the command trigger, if the trigger is found it will call the function IRC_BOT_TRIGGERED($command) But there will be loads more functions that can be called. What I want to do is be able to see if the user has defined a function to be called when an event happens, say there are more events such as a ping being recieved etc, but I want to only call the function if the user has defined it in the plugin file, is this possible? To help a bit more, kind of like using #ifndef in C++, I want to be able to see if the function is defined before trying to call it, as it will meet an error if it isn't defined. Pretty much exactly how the Messenger Live Plus scripting plugins work. Any help or pointers to the right direction will be appreciated. Thanks DELmE Edited May 11, 2010 by DELmE Share this post Link to post Share on other sites
AdmiralAlkex 125 Posted May 10, 2010 Couldn't you do that through Call()? It will set @error and @extended if the function doesn't exist or the parameters are wrong, see helpfile. .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 Share this post Link to post Share on other sites
PsaltyDS 39 Posted May 10, 2010 Couldn't you do that through Call()? It will set @error and @extended if the function doesn't exist or the parameters are wrong, see helpfile. Cute. One of those dusty corners of the help file I never dug into. Tested it with this: For $n = 1 To 3 Call("_Func" & $n) ConsoleWrite($n & ": @error = " & @error & "; @extended = " & @extended & @LF) Next Func _Func1() ConsoleWrite("One" & @LF) EndFunc Func _Func3() ConsoleWrite("Three" & @LF) EndFunc Thanks for the teachable moment. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites
evilertoaster 3 Posted May 10, 2010 Internally, AutoIt (used to) make a call to the internal function Parser_FindUserFunction() do explicitly find if a user function is in place. From the public facing functions, AdlibRegister(),HotKeySet(), GUICtrlSetOnEvent(), Execute() and Call() all use this, so could theoretically be used (by checking the @error/@extended) to find if a function exists. Share this post Link to post Share on other sites
delme 0 Posted May 11, 2010 Thanks for all the replys guys, they are all very helpful Share this post Link to post Share on other sites