Mr.Furious Posted April 14, 2005 Posted April 14, 2005 (edited) Is it possible to get a variable to go to a function. i.e. $Name = "Animals" $Next = "Art()" Common() Func Common() $msg = MsgBox(4099, "Please Choose", "Install files for " & $Name & "?", 8) If $msg = 7 then $Next If $msg = 2 then exit RunWait ("OpenAll+.exe Letters\" & $Name & "\") $Next EndFunc Func Art() $Name = "Art" $Next = "Bon()" Common() EndFunc Edited April 14, 2005 by Mr.Furious
buzz44 Posted April 14, 2005 Posted April 14, 2005 (edited) You mean can you use a variable that you use in a function outside it? And yes can do something like this $Next = "Bon()" With out the quotation marks and only if the function returns something. eg. $Next = Bon() Msgbox(0,"Co-ordinates", "X: " & $Next[0] & " Y: " & $Next [1]) Func Bon() $Pos = MouseGetPos() Return $Pos EndFunc Edited April 14, 2005 by Burrup qq
Mr.Furious Posted April 14, 2005 Author Posted April 14, 2005 Actually I want to jump to another area in the script to get the next set of variables and I will need to do this many times. There doesn't seem to be goto in autoit so I was trying to use functions to have areas to have the script goto. so basically I was trying to jump out of the function to another function to get the next set of variables. I can't get it to work as expected however.
buzz44 Posted April 14, 2005 Posted April 14, 2005 Just call the function when you need it. Or in the function get it to read the variables from another one and have lots of functions. If you dont put Global $Var at in your script you wont be able to use the variables created by a function in another function. qq
Mr.Furious Posted April 14, 2005 Author Posted April 14, 2005 (edited) I am starting to feel real stupid here cause I cant seem to get it to work. Here is a sample of what I got. Global $Name Global $Next Animals() Func Common() $msg = MsgBox(4099, "Please Choose", "Install All Letters For " & $Name & "?" & @CR & @CR & "Automatic installation if no response within 8 seconds", 8) If $msg = 7 then Return $Next If $msg = 2 then exit RunWait ("OpenAll+.exe Letters\" & $Name & "\") Return $Next EndFunc Func Animals() $Name = "Animals" $Next = Art() Common() EndFunc Func Art() $Name = "Art" $Next = Bon() Common() EndFunc Func Bon() $Name = "Bon Appetit" $Next = Done() Common() EndFunc Func Done() $Name = 0 $Next = 0 Exit EndFunc Edited April 14, 2005 by Mr.Furious
buzz44 Posted April 14, 2005 Posted April 14, 2005 (edited) I think I understand what you want. $msg = MsgBox(4099, "Please Choose", "Install All Letters For Animals?" & @CR & @CR & "Automatic installation if no response within 8 seconds", 8) If $msg = 6 then RunWait ("OpenAll+.exe Letters\Animals\") ElseIf $msg = 2 Then Exit EndIf $msg = MsgBox(4099, "Please Choose", "Install All Letters For Art?" & @CR & @CR & "Automatic installation if no response within 8 seconds", 8) If $msg = 6 then RunWait ("OpenAll+.exe Letters\Art\") ElseIf $msg = 2 Then Exit EndIf $msg = MsgBox(4099, "Please Choose", "Install All Letters For Bon Appetit?" & @CR & @CR & "Automatic installation if no response within 8 seconds", 8) If $msg = 6 then RunWait ("OpenAll+.exe Letters\Bon Appetit\") ElseIf $msg = 2 Then Exit EndIf Edited April 14, 2005 by Burrup qq
Developers Jos Posted April 14, 2005 Developers Posted April 14, 2005 I am starting to feel real stupid here cause I cant seem to get it to work.Here is a sample of what I got.<{POST_SNAPBACK}>The issue is that the script follows this path:Call Animals()Animals calls Art()Art calls Bon()Bon calls Done()Done does Exit ! 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.Â
Mr.Furious Posted April 14, 2005 Author Posted April 14, 2005 This is how I started but seemed bloated and messy when your talking about 75 plus items. I got carried away trying to make it streamlined.I think I understand what you want.$msg = MsgBox(4099, "Please Choose", "Install All Letters For Animals?" & @CR & @CR & "Automatic installation if no response within 8 seconds", 8) If $msg = 6 then RunWait ("OpenAll+.exe Letters\Animals\") ElseIf $msg = 2 Then Exit EndIf $msg = MsgBox(4099, "Please Choose", "Install All Letters For Art?" & @CR & @CR & "Automatic installation if no response within 8 seconds", 8) If $msg = 6 then RunWait ("OpenAll+.exe Letters\Art\") ElseIf $msg = 2 Then Exit EndIf $msg = MsgBox(4099, "Please Choose", "Install All Letters For Bon Appetit?" & @CR & @CR & "Automatic installation if no response within 8 seconds", 8) If $msg = 6 then RunWait ("OpenAll+.exe Letters\Bon Appetit\") ElseIf $msg = 2 Then Exit EndIf<{POST_SNAPBACK}>
Mr.Furious Posted April 14, 2005 Author Posted April 14, 2005 Yah that's exactly what happens damn thing. Bounces from next to next and doesn't do my common task.Is this just not going to work out and I should use the bloated way?The issue is that the script follows this path:Call Animals()Animals calls Art()Art calls Bon()Bon calls Done()Done does Exit !<{POST_SNAPBACK}>
mdes Posted April 14, 2005 Posted April 14, 2005 What you want is COROUTINE, isn't it ? ps: Why are there only the 3 first volumes from D. Knuth "The Art of Computer Programming" ? Gestion des congés, RTT, vacances scolaires, autres absences sur Pocket PC : CongésRFV
zcoacoaz Posted April 14, 2005 Posted April 14, 2005 (edited) I think i know what he wants, he wants to store a variable name then call that. To do it use code like this: $Call = "Function" Call ( $Call ) Func Function() MsgBox ( 0, "Example", "I called $Call which enabled this box to show" & @CRLF & "$Call=" & $Call ) EndFunc Edited April 14, 2005 by Xenogis [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]
Mr.Furious Posted April 14, 2005 Author Posted April 14, 2005 (edited) Call seems to work the same as return and still produces the same strange run as JdeB mentioned Sure be easier if could have a section :Art $name="art" $next="bon" Common() and just get the function to goto the art section get the varibles run the msgbox then move on to the next section and so on and so on Edited April 14, 2005 by Mr.Furious
zcoacoaz Posted April 14, 2005 Posted April 14, 2005 What about this using my suggestion? Global $Name Global $Next Animals() Func Common() $msg = MsgBox(4099, "Please Choose", "Install All Letters For " & $Name & "?" & @CR & @CR & "Automatic installation if no response within 8 seconds", 8) If $msg = 7 then Call ( $Next ) If $msg = 2 then exit RunWait ("OpenAll+.exe Letters\" & $Name & "\") Call ( $Next ) EndFunc Func Animals() $Name = "Animals" $Next = "Art" Common() EndFunc Func Art() $Name = "Art" $Next = "Bon" Common() EndFunc Func Bon() $Name = "Bon Appetit" $Next = "Done" Common() EndFunc Func Done() $Name = 0 $Next = 0 Exit EndFunc [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]
Mr.Furious Posted April 14, 2005 Author Posted April 14, 2005 (edited) Wooo hooo you got it to work!! Thanks, thanks, thanks!! Problem was when I was using your suggestoin I had the brackets in there: $Next = "Art()" Instead of $Next = "Art" Edited April 14, 2005 by Mr.Furious
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