# HELP!

## Recommended Posts

I am currently making a scrpt with 2 MILLION differnt optoins

```\$button1 = GUICtrlCreateButton("1", 10, 10, 60)
\$button2 = GUICtrlCreateButton("2", 10, 40, 60)
\$button3 = GUICtrlCreateButton("3", 10, 70, 60)
\$button4 = GUICtrlCreateButton("4", 10, 100, 60)
\$button5 = GUICtrlCreateButton("5", 10, 130, 60)
\$button6 = GUICtrlCreateButton("6", 10, 160, 60)
\$button7 = GUICtrlCreateButton("7", 10, 190, 60)
\$button8 = GUICtrlCreateButton("8", 10, 220, 60)
\$Checkbox1 = GUICtrlCreateCheckbox("1 ", 130, 10)
\$Checkbox2 = GUICtrlCreateCheckbox("2 ", 130, 40)
\$Checkbox3 = GUICtrlCreateCheckbox("3 ", 130, 70)
\$Checkbox4 = GUICtrlCreateCheckbox("4 ", 130, 100)
\$Checkbox5 = GUICtrlCreateCheckbox("5 ", 130, 130)
\$Checkbox6 = GUICtrlCreateCheckbox("6 ", 130, 160)
\$Checkbox7 = GUICtrlCreateCheckbox("7 ", 130, 190)
\$Checkbox8 = GUICtrlCreateCheckbox("8 ", 130, 220)```

I made that genaric so its easyer to read, but doing the math i have 8! x 60 which is a little over 2,500,000 differnt options. Any ideas on how to speed up writing this script?

##### Share on other sites

For Loop.... Some math...

Button 1-8:

```\$x = 1
For \$i = 10 to 220 Step 30
Assign ("Button"&\$x, "GUICtrlCreateButton('"&\$x&"', 10, "&\$i&", 60)")
\$x += 1
Next```

I'm pretty sure this has been asked before. Take a look around in here, back a few pages.

Edited by Bert

##### Share on other sites

Here's working example of creating controls in a loop to an array

So you can see how to identify a controls in the arrays I also set a msgbox when a control is clicked ..

There's more then 1 way to do what your after.

```#include <GUIConstants.au3>

\$Main = GUICreate("Controls", 165, 255)
\$y = 10
For \$b = 1 To 8
\$Button[\$b] = GUICtrlCreateButton(\$b, 10, \$y, 60)
\$Checkbox[\$b] = GUICtrlCreateCheckbox(\$b & " ", 130, \$y)
\$y = \$y + 30
Next
GuiSetState(@SW_SHOW)

While 1
\$msg = GUIGetMsg()
Select
Case \$msg = \$GUI_EVENT_CLOSE
ExitLoop
EndSelect
For \$i = 1 To 8
Select
Case \$msg = \$Button[\$i]
MsgBox(0,'Button ' & \$i, 'Button ' & \$i & ' was clicked', 1)
MsgBox(0,'Radio ' & \$i, 'Radio ' & \$i & ' was selected', 1)
Case \$msg = \$Checkbox[\$i]
MsgBox(0,'Checkbox ' & \$i, 'Checkbox ' & \$i & ' is checked', 1)
Else
MsgBox(0,'Checkbox ' & \$i, 'Checkbox ' & \$i & ' is unchecked', 1)
EndIf
EndSelect
Next
WEnd```

Even though this example is longer then what you posted , remeber this code actually runs..

Cheers

## Create an account

Register a new account

×

• Wiki

• Back

• Git