Jump to content

HELP!


Mintz
 Share

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)
$Radio1 = GUICtrlCreateRadio("1 ", 80, 10)
$Radio2 = GUICtrlCreateRadio("2 ", 80, 40)
$Radio3 = GUICtrlCreateRadio("3 ", 80, 70)
$Radio4 = GUICtrlCreateRadio("4 ", 80, 100)
$Radio5 = GUICtrlCreateRadio("5 ", 80, 130)
$Radio6 = GUICtrlCreateRadio("6 ", 80, 160)
$Radio7 = GUICtrlCreateRadio("7 ", 80, 190)
$Radio8 = GUICtrlCreateRadio("8 ", 80, 220)
$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?

Link to comment
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
Link to comment
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>

Global $Button[9], $Radio[9], $Checkbox[9]

$Main = GUICreate("Controls", 165, 255)
$y = 10
For $b = 1 To 8
    $Button[$b] = GUICtrlCreateButton($b, 10, $y, 60)
    $Radio[$b] = GUICtrlCreateRadio($b & " ", 80, $y)
    $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)
            Case $msg = $Radio[$i] 
                MsgBox(0,'Radio ' & $i, 'Radio ' & $i & ' was selected', 1)
            Case $msg = $Checkbox[$i]
                If GUICtrlRead($Checkbox[$i]) = 1 Then
                    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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...