Jump to content

Array iterations for 2D arrays


Recommended Posts

Hi, Ive ran into some problems working with 2d arrays...

Im trying to substitute a Class type with a 2d array, so each element of the array can contain 2 values:

Dim array[30][2]

I want the first part of each element to contain a GUI checkbox, and the 2nd part to contain TRUE if it is checked and FALSE if it is unchecked...How would I go about doing this?

Also how would I iterate through this kind of array if I only want to look at the first part of each element?

"For $i[0] in $array" doesnt seem to work

Link to comment
Share on other sites

  • Developers

This will fill the array with the state of the checkboxes assuming Contol handles are loaded in the first value

For $x = 0 to Ubound($array)-1
     GuiRead($array[$x][1]) = GuiRead($array[$x][0])
Next

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.
  :)

Link to comment
Share on other sites

kinda like...

Dim $array[30][2]

For $x = 1 to UBound($array) -1
    $array[$x][1] = GUICtrlCreateCheckbox(.....)
Next

; OR....

$array[1][1] = GUICtrlCreateCheckbox(.....)
$array[2][1] = GUICtrlCreateCheckbox(.....)
$array[3][1] = GUICtrlCreateCheckbox(.....)
$array[4][1] = GUICtrlCreateCheckbox(.....)
;......... 


; to check for true or false

For $i = 1 to UBound($array) - 1
    If BitAnd(GUICtrlRead($array[$i][1]),$GUI_CHECKED) = $GUI_CHECKED Then
        $array[$i][2] = "True"
    Else
        $array[$i][2] = "False"
    EndIf
Next

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Developers

Dim $array[30][2]

For $x = 1 to UBound($array) -1
    $array[$x][1] = GUICtrlCreateCheckbox(.....)
Next

; OR....

$array[1][1] = GUICtrlCreateCheckbox(.....)
$array[2][1] = GUICtrlCreateCheckbox(.....)
$array[3][1] = GUICtrlCreateCheckbox(.....)
$array[4][1] = GUICtrlCreateCheckbox(.....)
;......... 
; to check for true or false

For $i = 1 to UBound($array) - 1
    If BitAnd(GUICtrlRead($array[$i][1]),$GUI_CHECKED) = $GUI_CHECKED Then
        $array[$i][2] = "True"
    Else
        $array[$i][2] = "False"
    EndIf
Next

8)

Need to use [0] and [1] ....[2] will give an error when running this .. :P

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.
  :)

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...