joehittn Posted November 12, 2007 Posted November 12, 2007 my attempt: i wanted to make a gui button to run a function, which contains another funciton... expandcollapse popup; Arbeitsvariablen Global $i ; Variablen - Workstationbezeichnungen (IPs) #include <Array.au3> Global $CompArray[26] $CompArray[1] = "r15" ..... ; Variablen - MAC-Adressen #include <Array.au3> Global $MacArray[26] $MacArray[1] = "00:04:76:8E:41:2D" ..... GUI-stuff... GUICtrlSetOnEvent($Button1, "Wakeup_all_schleife") ; Functions Func Wakeup_all_schleife () for $i = 1 to 2 Wakeup_all () Next Exit EndFunc Func Wakeup_all () sleep (500) send ("#r", 0) sleep (500) send ("cmd", 0) sleep (500) send ("{enter}") sleep (500) send("Z:") send ("{enter}") send("cd Z:\temp\aktuelles\") sleep (500) send ("{enter}") send ("wolcmd " & $MacArray[$i] & " " & $CompArray[$i] & " 255.255.255.0 80", 1) send ("{enter}") sleep (2000) WinClose("Untitled - Notepad", "") EndFunc i guess its a problem with the $i variable used in the for-loop, which cant be used afterwards in the function, but aehm, i dont know why that is and how i could get around this... thnx in advance, joehittn
PsaltyDS Posted November 12, 2007 Posted November 12, 2007 The For keyword automatically declares a local variable, I believe, so the For/Next is working with the local $i but your second function is using the global one. Just dump the global and pass the variable as a parameter: ; Functions Func Wakeup_all_schleife () for $i = 1 to 2 Wakeup_all ($i) Next Exit EndFunc Func Wakeup_all ($n) ; ... send ("wolcmd " & $MacArray[$n] & " " & $CompArray[$n] & " 255.255.255.0 80", 1) send ("{enter}") sleep (2000) WinClose("Untitled - Notepad", "") EndFunc You don't have to rename the variable from $i to $n in the second function, I just did it to enphasize what was being done. 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
Nahuel Posted November 12, 2007 Posted November 12, 2007 (edited) Well of course... you could do something like this: Func Wakeup_all_schleife () for $i = 1 to 2 Wakeup_all ($i) Next Exit EndFunc Func Wakeup_all ($a) sleep (500) send ("#r", 0) sleep (500) send ("cmd", 0) sleep (500) send ("{enter}") sleep (500) send("Z:") send ("{enter}") send("cd Z:\temp\aktuelles\") sleep (500) send ("{enter}") send ("wolcmd " & $MacArray[$a] & " " & $CompArray[$a] & " 255.255.255.0 80", 1) send ("{enter}") sleep (2000) WinClose("Untitled - Notepad", "") EndFunc -edit- Listen to the penguin! Edited November 12, 2007 by Nahuel
joehittn Posted November 12, 2007 Author Posted November 12, 2007 thanks a lot to the animals of the sea or lake or antarctica!! :-) works fine now! cheers
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