JonathanChan Posted September 11, 2004 Posted September 11, 2004 Hello... I'm upgrading from AutoIt 2 to AutoIt 3... I have this script that has this subprocedure that i access using Goto. How would i go about doing it without goto? I don't want to copy and paste this thing in the code 1 dozen times... The code is something like this (except 10x more complicated): (nevermind the incorrect syntax and incorrect commands of this code... it's just an example... it's like AUT and AU3 code in 1 file... messy... sorry...i don't want to grab the whole thing).. Do click, 35, 35 send, etc. etc. etc. If windowstitle = "bad popup" then goto subprocedure $test = $test + 1 Until $test = 10 Do Click, 62,235 send, etc. etc. etc. If windowstitle = "bad popup" then goto subprocedure $test = $test + 1 Until $test = 10 :subprocedure RightClick, 23, 34 etc. etc. return This is just an example... but in my real working copy... :subprocedure is like 100 lines and the other parts of the script is much more complicated... Any help much appreciated... Thanks! Jonathan Chan
Andre Posted September 11, 2004 Posted September 11, 2004 Hi, Read the manual about procedures ? Andre What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Lazycat Posted September 11, 2004 Posted September 11, 2004 Autoit 3 have "functions" which you can use instead goto calls which returns into same place. It much more clean and flexible way. For example your pseudo-code will looks like: Do click, 35, 35 send, etc. etc. etc. If windowstitle = "bad popup" then subprocedure () $test = $test + 1 Until $test = 10 Do Click, 62,235 send, etc. etc. etc. If windowstitle = "bad popup" then subprocedure () $test = $test + 1 Until $test = 10 Func subprocedure () RightClick, 23, 34 etc. etc. EndFunc BTW very similar example exists in the very good file located in the Autot folder - AutoIt.chm Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s])
JonathanChan Posted September 12, 2004 Author Posted September 12, 2004 Autoit 3 have "functions" which you can use instead goto calls which returns into same place. It much more clean and flexible way. For example your pseudo-code will looks like: BTW very similar example exists in the very good file located in the Autot folder - AutoIt.chm <{POST_SNAPBACK}>Sorry! I was reading the manual and i freaked when Jon said that goto was evil and bad... I thought he got rid of the whole thing altogether... Didn't see anything about procedures... Thanks! Jonathan Chan
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