Sign in to follow this  
Followers 0
probedrone

Array iterations for 2D arrays

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


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

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Awh... you caught it just before i did

or...

use

Dim $array[30][3]

and it will work ok

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0