Jump to content

Multidimensional arrays


Recommended Posts

Hello,

I am trying to make a menu item for a domain so it will take them to the right site but it keeps giving me errors

Code Snippet...

$domain = _ArrayCreate( _
_ArrayCreate('Australia','.au'), _
_ArrayCreate('Belgium','.be'), _
_ArrayCreate('Canada','.ca'), _
_ArrayCreate('France','.fr'), _
_ArrayCreate('Germany','.de'), _
_ArrayCreate('Ireland','.ie'), _
_ArrayCreate('Italy','.it'), _
_ArrayCreate('Netherlands','.nl'), _
_ArrayCreate('New Zealand','.com/nz'), _
_ArrayCreate('Philippines','.ph'), _
_ArrayCreate('Poland','.pl'), _
_ArrayCreate('Spain','.es'), _
_ArrayCreate('Switzerland','.ch'), _
_ArrayCreate('United Kingdom','.co.uk'), _
_ArrayCreate('United States','.com') _
)

For $x = 0 To 14
    $domainitem = GUICtrlCreateMenuitem($domain[$x][0],$domainmenu)
Next
[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
Link to comment
Share on other sites

Its all there, its an array of arrays is this not what you wanted to do?

#include<Array.au3>
$domain = _ArrayCreate( _
_ArrayCreate('Australia','.au'), _
_ArrayCreate('Belgium','.be'), _
_ArrayCreate('Canada','.ca'), _
_ArrayCreate('France','.fr'), _
_ArrayCreate('Germany','.de'), _
_ArrayCreate('Ireland','.ie'), _
_ArrayCreate('Italy','.it'), _
_ArrayCreate('Netherlands','.nl'), _
_ArrayCreate('New Zealand','.com/nz'), _
_ArrayCreate('Philippines','.ph'), _
_ArrayCreate('Poland','.pl'), _
_ArrayCreate('Spain','.es'), _
_ArrayCreate('Switzerland','.ch'), _
_ArrayCreate('United Kingdom','.co.uk'), _
_ArrayCreate('United States','.com') _
)

For $i = 1 to ubound($domain) -1
    _ArrayDisplay($Domain[$i],"")
Next
Link to comment
Share on other sites

Is this more what you were wanting?

#include <GUIConstants.au3>
Local $Domain[7][2]

$Domain[1][0] = 'Australia'
$Domain[1][1] = '.au'
$Domain[2][0] = 'Belgium'
$Domain[2][1] = '.be'
$Domain[3][0] = 'Canada'
$Domain[3][1] = '.ca'
$Domain[4][0] = 'France'
$Domain[4][1] = '.fr'
$Domain[5][0] = 'Italy'
$Domain[5][1] = '.it'
$Domain[6][0] = 'Netherlands'
$Domain[6][1] = '.nl'


_ArrayDisplay2($Domain)

Func _ArrayDisplay2(Const ByRef $avArray, $sTitle = "")
    
    If (Not IsArray($avArray)) Then
        SetError(1)
        Return 0
    EndIf
    
    Local $iRows = 0, $iCols = 0, $cHeaders, $iCnt = 0, $lv ,$lCnt = 0, $tCnt = 0, $rtext, $cButton,$lvGui,$lvGuiMsg

    $iRows = Ubound($avArray) -1
    $icols = Ubound($avArray,2)
    
    $cHeaders = "I/C |0|"
    
    For $iCnt = 1 to $iCols -1
        $cHeaders &= $iCnt & "|"
    Next
    
    $lvGui = GuiCreate($sTitle,400,300)
    $lv= GuiCtrlCreateListview($cHeaders,20,20,360,220)
    
If $icols <> 0 then 
    
    For $lCnt = 0 to $iRows
        $rtext = "[" & $lCnt &"]|"
        For $tCnt = 0 to $icols -1
            $rText &= $avArray[ $lcnt][$tcnt] & "|"
        Next
        GUICtrlCreateListViewItem($rText,$lv)
    Next
    
Else
    
    For $lCnt = 0 to $iRows
        $rtext = "[" & $lCnt &"]|" & $avArray[$lCnt]
        GUICtrlCreateListViewItem($rText,$lv)
    Next
    
    
EndIf


$cButton = GuiCtrlCreateButton("Close", 150, 260, 110, 30)


GuiSetState()

While 1
    $lvGuiMsg = GuiGetMsg(1)
    Select
        Case $lvGuiMsg[0] = $GUI_EVENT_CLOSE or $lvGuiMsg[0] = $cButton
        If $lvGuiMsg[1] = $lvGui then ExitLoop
        
        Case Else
        ;;;
    EndSelect
WEnd
    
    SetError(0)
    Return 1

EndFunc
Link to comment
Share on other sites

  • Developers

_ArrayCreate is intended to create single dimension arrays and AutoIt3 has its own internal way now to create and "fill" arrays:

Dim $domain[15][2] = [['Australia', '.au'],['Belgium', '.be'],['Canada', '.ca'],['France', '.fr'], _
        ['Germany', '.de'],['Ireland', '.ie'],['Italy', '.it'],['Netherlands', '.nl'], _
        ['New Zealand', '.com/nz'],['Philippines', '.ph'],['Poland', '.pl'],['Spain', '.es'], _
        ['Switzerland', '.ch'],['United Kingdom', '.co.uk'],['United States', '.com']]
For $x = 0 To 14
    ConsoleWrite($domain[$x][0]&@LF)
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

_ArrayCreate is intended to create single dimension arrays and AutoIt3 has its own internal way now to create and "fill" arrays:

Dim $domain[15][2] = [['Australia', '.au'],['Belgium', '.be'],['Canada', '.ca'],['France', '.fr'], _
        ['Germany', '.de'],['Ireland', '.ie'],['Italy', '.it'],['Netherlands', '.nl'], _
        ['New Zealand', '.com/nz'],['Philippines', '.ph'],['Poland', '.pl'],['Spain', '.es'], _
        ['Switzerland', '.ch'],['United Kingdom', '.co.uk'],['United States', '.com']]
For $x = 0 To 14
    ConsoleWrite($domain[$x][0]&@LF)
Next
Thanks you ROCK! :)
[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
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...