saywell Posted July 30, 2010 Share Posted July 30, 2010 (edited) I'm developing my skills in Autoit, but not yet mastered it!! My first question is escaping fro within a user-defined function. I'd like to end the function prematurely using a If statement - eg If $var = 1 Then endfunc endif You can do this with a exit command, from the whole script, but adding a conditional endfunc throws up an error. The helpfile says "Use the Return keyword to exit the function." but gives no syntax or example. Or maybe I'm not reading it right? Can anyone shed light on this? Preferably with an example or two! My second is probably a more general programming question. The word.au3 file uses 'getcollection' quite a lot in the examples, where it would seem to work with just the following command. What is the underlying meaning of a 'collection' in this context, as I don't really understand the concept. If anyone could expalin or point me towards a [fairly basic] tutorial on the internet I'd be grateful. Thanks, William Edited July 30, 2010 by saywell Link to comment Share on other sites More sharing options...
Developers Jos Posted July 30, 2010 Developers Share Posted July 30, 2010 1. Look at the Helpfile topic: Func...Return...EndFunc SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 30, 2010 Share Posted July 30, 2010 2. Collection means an array of COM objects, which you would walk through with For/In/Next. See OBJ/COM Reference in the help file. 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 Link to comment Share on other sites More sharing options...
saywell Posted July 30, 2010 Author Share Posted July 30, 2010 1. Look at the Helpfile topic: Func...Return...EndFuncWell, I did just that - and even pasted a quote from it in my original query! So I don't think your reply has added to my undersatnding of the situation!The examples are using the word ' in the context of 'Return' in the cotext of returning a result, not as a way of prematurely terminating the function as indicated in the quote Use the Return keyword to exit the function. Perhaps soemone else can clarify this for me?William Link to comment Share on other sites More sharing options...
Developers Jos Posted July 30, 2010 Developers Share Posted July 30, 2010 (edited) Well, your question was how to stop and return from a Func...EndFunc before the end and the answer is : Return (not Exit which stop the Script execution). Jos edit: sorry I didn't read about the "someone else bit before answering" .. so My apologise for answering anyway. Edited July 30, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
saywell Posted July 30, 2010 Author Share Posted July 30, 2010 2. Collection means an array of COM objects, which you would walk through with For/In/Next. See OBJ/COM Reference in the help file.Thanks, PsaltyDS - I'll see if the links at the end are simple enough for me!So for doing a single action , the get collection may not be necessary - only if doing multiple processes in a loop?William Link to comment Share on other sites More sharing options...
saywell Posted July 30, 2010 Author Share Posted July 30, 2010 Well, your question was how to stop and return from a Func...EndFunc before the end and the answer is : Return (not Exit which stop the Script execution).Josedit: sorry I didn't read about the "someone else bit before answering" .. so My apologise for answering anyway.That's OK, Jos! You've helped this time by indicating that return is to function as exit is to script. The value then is whatever I specify to be what the func returns to the calling process? Is that right?These things are not always as evident as you might expect, to someone who's not used them before!ThanksWilliam Link to comment Share on other sites More sharing options...
Developers Jos Posted July 30, 2010 Developers Share Posted July 30, 2010 I understand but it really is explained in the Helpfile page I pointed to. Use the Return keyword to exit the function. Unlike built-in functions, user-defined functions return 0 unless another return value is specified.Just have a play with it and you see its pretty strait forward.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
saywell Posted July 30, 2010 Author Share Posted July 30, 2010 I understand but it really is explained in the Helpfile page I pointed to. Just have a play with it and you see its pretty straight forward.JosYup, you're right it is straightforward. But I read it a number of times without coming to that conclusion! It was the second part of the quote that put me off track.Regards,William 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