sulfurious Posted August 6, 2005 Share Posted August 6, 2005 HI. Here is one that is stumping me. $Glist has an array already in it. I can run this minus the ctrlsetonevent and it builds the buttons just like i want. I cannot figure out how to get the variable into the function spot on that OnEvent line though. I have tried lot's of different structuring of the variable, with and without quotes in most all spots. It checks ok in scite, but errors out once you come to it, saying it is an unknown function. As you can see the function is not complete. Stuck on this line. Any ideas? $bHT = 0 For $z = 1 to $Glist[0] - 1 $bHT = $bHT + 50 $btn = "btnG" & $z $dloadV = "_dload($Glist[" $dloadVa = $z & "])" $dloadVal = '"' & $dloadV & $dloadVa & '"' $btn = GUICtrlCreateButton(StringTrimRight($Glist[$z], 1), 30, $bHT) GUICtrlSetOnEvent($btn, $dloadVal) Next Func _dload($DLname) ; MsgBox(0, "", "G" & $z " is " & $DLname) EndFunc;===> END DLOAD Thnx, sul Link to comment Share on other sites More sharing options...
GaryFrost Posted August 6, 2005 Share Posted August 6, 2005 arguments for functions used in events are not allowed. if you set the variable to just the function name, and take the argument out of the function you get no errors. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
sulfurious Posted August 6, 2005 Author Share Posted August 6, 2005 (edited) I am unable to solve this. I tried to understand what you were saying, so I just concentrated on properly naming each button so I could use that later in the function, but .... The goal. Dump a list of app names into the array $Glist. Next, create a button for each value in the array. Next, define a function that starts to download the value of the array based on the variable assigned to the create button function, in other words make the $variable = SetOnEvent the same as the $variable = CreateButton. This way I can edit that text file and have the form change on the fly. Here is the code I have now, which gets to the function, but I don't think it has a $variable = for the createbutton function. $bHT = 0 Dim $btn[$Glist[0]], $btnG, $btn1 For $z = 1 to $Glist[0] - 1 $bHT = $bHT + 50 ;$btnG[$x] = "$btnG" & $x & " create button " & $Glist[$x] ;$btnG = $z ;$btn = "$btnG" & $z ;$btnG = $btn[$z] $btn[$z] = "$btn" & $z = GUICtrlCreateButton(StringTrimRight($Glist[$z], 1), 30, $bHT) GUICtrlSetOnEvent(-1, "_dload") Next Func _dload() MsgBox(0, "you clicked", "something") EndFunc;===> END DLOAD Like I said, I can get each button to run the _dload function, but I cannot refer to what the button should be called, which in this case should be $btn1 - $btn4. I am at a loss. Any ideas here? Thnx, sul Edited August 6, 2005 by sulfurious Link to comment Share on other sites More sharing options...
PartyPooper Posted January 6, 2006 Share Posted January 6, 2006 I need to do something similar to this. Any solution? Link to comment Share on other sites More sharing options...
kjactive Posted January 6, 2006 Share Posted January 6, 2006 (edited) I use a walk around like this... Global $Last_clicked_control_var For $a = to 4 Create the controls.... Next While 1 $msg = GUIGetMsg(1) select case ... case ... Endselect $Last_clicked_control_var = $msg[0] ; this global variable would automatically point to last pressed control WEnd This is a walkaround and it would be nice to be able to pass arrays or just a value to event functions included the hotkey opt but as this one could get the values available in event functions... kjactive Edited January 6, 2006 by kjactive Au3PP 4.1 - Autoit3 preprocessor, optimize speed, performance to scripts and do executes....[/url]Au3Calibur - Create libraries of commonly used code excerptsWords manipulate UDF, functions that is lent from the rexx language, topics and index file includedCustomDialog UDF to include custom made dialogs like a extended colorpick requester to scripts...[url="ftp://fritidshjemmet.com/Autoit3/SysColor.zip"]SysColor UDF a low level color library to manipulate RGB and Hex values...Shell32 UDF to Automate Windows® operating tasks from native dialog and Wizards browsers... Optimized the CodeWicard with options to generate browser code etc... Link to comment Share on other sites More sharing options...
PartyPooper Posted January 7, 2006 Share Posted January 7, 2006 Ah, ok thanks. I ended up doing something a little different as the variable I wanted to pass was just the button number that was pressed. GUICtrlSetOnEvent($hButton[$i], "RunProg"); where $i is the button number Func RunProg() For $i = 1 to $iLastButton If @GUI_CtrlId = $hButton[$i] Then ExitLoop Next .... EndFunc 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