Jump to content

multi dim array problem


Recommended Posts

hello everyone,

i wanted to improve an old script but i'm facing a stupid problem and i'm stucked there ...

here's what i want to do:

i'm using an ini file with sections and idents. i stored sections into a comma variable which a explode to get each section name.

for each section there's another variable containing all idents that can be read into that section.

the aim is to call into the script "$params[$section][$ident]" to read values.

; script

$sections = "info,global"

$section_info = "main,window"

; ini

[info]

main=title

window=explorer

I tried several ways of creating a variable such as "$params[$section][$ident]" but all i get is compiler errors...

Can someone help plz ?

Link to comment
Share on other sites

nope dont work

actually the problem seem to be the way i create my array, because i can read $params[$section] but not $params[$sections][whatever]

i declare the first array, then using <Array.au3> and _ArrayAdd i try this

_ArrayAdd($params[$section], $ident)

however when compiler sends its error it look like this is dim error

i just dont get it :s

Link to comment
Share on other sites

hello everyone,

i wanted to improve an old script but i'm facing a stupid problem and i'm stucked there ...

here's what i want to do:

i'm using an ini file with sections and idents. i stored sections into a comma variable which a explode to get each section name.

for each section there's another variable containing all idents that can be read into that section.

the aim is to call into the script "$params[$section][$ident]" to read values.

; script

$sections = "info,global"

$section_info = "main,window"

; ini

[info]

main=title

window=explorer

I tried several ways of creating a variable such as "$params[$section][$ident]" but all i get is compiler errors...

Can someone help plz ?

Are you looking for an end result of a 2-dim or 3-dim array? If it's 3-dim, give this a shot:

CODE

#cs

IniToArray - Reads the section names and section(s) content

into a 3-dimensional array.

Change the $showEmptySections value to a "1" if you want to see

sections with no content in the results.

#ce

#include <Array.au3>

$iniSource = @ScriptDir & "\test.ini"

$showEmptySections = 0

$sections = IniReadSectionNames($iniSource)

Dim $aINIContent[1][3] = [["0", "", ""]]

If Not IsArray($sections) Then

$aINIContent[0][1] = "<No sections found>"

_ArrayDisplay($aINIContent)

Exit

EndIf

For $i = 1 To $sections[0]

_AddContent($sections[$i])

Next

_ArrayDisplay($aINIContent)

Func _AddContent($contentSection)

$contents = IniReadSection($iniSource, $contentSection)

If IsArray($contents) Then

For $j = 1 To $contents[0][0]

ReDim $aINIContent[uBound($aINIContent) + 1][3]

$aINIContent[0][0] = $aINIContent[0][0] + 1

$activeLine = $aINIContent[0][0]

$aINIContent[$activeLine][0] = $contentSection

$aINIContent[$activeLine][1] = $contents[$j][0]

$aINIContent[$activeLine][2] = $contents[$j][1]

Next

Else

If $showEmptySections Then

ReDim $aINIContent[uBound($aINIContent) + 1][3]

$aINIContent[0][0] = $aINIContent[0][0] + 1

$activeLine = $aINIContent[0][0]

$aINIContent[$activeLine][0] = $contentSection

$aINIContent[$activeLine][1] = "<Section Empty>"

EndIf

EndIf

;_ArrayDisplay($contents)

EndFunc

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

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