Jump to content

Multidimension array issue


ondrovic
 Share

Recommended Posts

I have created a multi dimension array $data[11][3] and I can get the item to display in a the GUI and populate checkboxes but I want the 2 item of the array to be read and if it's 1 then load the checkbox if not then skip that item can anyone let me know where or what I am doing wrong?

Func _CreateApplications()
#cs
  $data[x][1] = Name
  $data[x][2] = Install | Not Install
  $data[x][3] = Checked | Not Checked
  $data[x][4] = Tooltip
#ce
$data[0][0] = "Test"
$data[0][1] = 1
$data[0][2] = 0
$data[0][3] = "Test"

$data[1][0] = "Test 1"
$data[1][1] = 0
$data[1][2] = 0
$data[1][3] = "Test 1"

$data[2][0] = "Test 2"
$data[2][1] = 0
$data[2][2] = 0
$data[2][3] = "Test 2"

$data[3][0] = "Test 3"
$data[3][1] = 0
$data[3][2] = 0
$data[3][3] = "Test 3"

$data[4][0] = "Test 4"
$data[4][1] = 0
$data[4][2] = 0
$data[4][3] = "Test 4"

For $i = 0 To UBound($data, 1) - 1
  For $j = 0 To UBound ($data,2) - 1
   If $data[0][$j] = 1 Then
    For $k = 0 To UBound($data,1) - 1
     $dataCB[$k] = GUICtrlCreateCheckbox($data[$k][0], 50, (20 * $k) + 138, 300, 20)
    Next
   EndIf
  Next
Next
GUISetState()
EndFunc
Link to comment
Share on other sites

ondrovic,

You were overly complicating it. See the following code.

_CreateApplications()

Func _CreateApplications()
#cs
  $data[x][1] = Name
  $data[x][2] = Install | Not Install
  $data[x][3] = Checked | Not Checked
  $data[x][4] = Tooltip
#ce

local $data[10][4]

$data[0][0] = "Test"
$data[0][1] = 1
$data[0][2] = 0
$data[0][3] = "Test"

$data[1][0] = "Test 1"
$data[1][1] = 0
$data[1][2] = 0
$data[1][3] = "Test 1"

$data[2][0] = "Test 2"
$data[2][1] = 0
$data[2][2] = 0
$data[2][3] = "Test 2"

$data[3][0] = "Test 3"
$data[3][1] = 3
$data[3][2] = 0
$data[3][3] = "Test 3"

$data[4][0] = "Test 4"
$data[4][1] = 0
$data[4][2] = 0
$data[4][3] = "Test 4"

For $i = 0 To UBound($data, 1) - 1
   If $data[$i][1] <> 0  Then
     ConsoleWrite('Hit at row = ' & $i & @LF)
   EndIf
Next
EndFunc

Also, you will find it easier to get help if you post runnable code.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

ondrovic,

You were overly complicating it. See the following code.

_CreateApplications()

Func _CreateApplications()
#cs
$data[x][1] = Name
$data[x][2] = Install | Not Install
$data[x][3] = Checked | Not Checked
$data[x][4] = Tooltip
#ce

local $data[10][4]

$data[0][0] = "Test"
$data[0][1] = 1
$data[0][2] = 0
$data[0][3] = "Test"

$data[1][0] = "Test 1"
$data[1][1] = 0
$data[1][2] = 0
$data[1][3] = "Test 1"

$data[2][0] = "Test 2"
$data[2][1] = 0
$data[2][2] = 0
$data[2][3] = "Test 2"

$data[3][0] = "Test 3"
$data[3][1] = 3
$data[3][2] = 0
$data[3][3] = "Test 3"

$data[4][0] = "Test 4"
$data[4][1] = 0
$data[4][2] = 0
$data[4][3] = "Test 4"

For $i = 0 To UBound($data, 1) - 1
If $data[$i][1] <> 0 Then
     ConsoleWrite('Hit at row = ' & $i & @LF)
EndIf
Next
EndFunc

Also, you will find it easier to get help if you post runnable code.

kylomas

Thanks and will do from now on :-)

Work great

Edited by ondrovic
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...