Jump to content
Sign in to follow this  
dali4u

array with more dimensions, how?

Recommended Posts

dali4u

Is it possible to use _ArrayAdd to add stuff to an array with 4 dimentions?

Share this post


Link to post
Share on other sites
Jos

Is it possible to use _ArrayAdd to add stuff to an array with 4 dimentions?

No, but why would you want to use that anyways when you can use Global/Local ?

By the way, are you sure you need 4 dimensions?


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
dali4u

yes, i do. I'm writing a GUI for a silent install DVD for our lab. The GUI read

all installable software from a INI and displays the sections af the INI as Tabs and the

content as GUICtrlCreateCheckbox and a Tip. The INI looks like:

name=Apollo 37zz

setup=.\media\Apollo37zz_SFX.exe

hint=Kleiner kostenloser MP3 Player

install=1

Just an example, the full INI contain over 80 different silent software SFX files in 10 different

sections.

1. read INI into an array with 5 dimentions (i found a solution :-)))

col0=Sectionname (the Sectionname will be useed as Tabname)

col1=name

col2=setup (the path to the EXE file)

col3=hint (the hint will be added as GUICtrlSetTip)

col4=install (1 means Checkbox set to true, 4 means not checked)

2. build GUI from that array

3. read GUI to mod the array

4. Func to readout the array and install the selected software

Meantime a found within this forum a solution to read the INI directly into an array with 5 dimentions...

Thx

Edited by dali4u

Share this post


Link to post
Share on other sites
ChrisL
dali4u

hmm, i think i have had a wrong point of view what "dimensions" mean. you are

right... sorry for my failure. n-columns does not mean n-dimentions...

Share this post


Link to post
Share on other sites
ChrisL

OK this is a 2d array with 5 "columns"

Using ReDim you can expand the array then insert the data

#include <array.au3>
Local $2dArrayWith5Columns[1][5]

Redim $2dArrayWith5Columns[Ubound($2dArrayWith5Columns) +1][UBound ($2dArrayWith5Columns,2)];increase the array by 1 row

$2dArrayWith5Columns[Ubound($2dArrayWith5Columns) -1][0] = "Last row Column 0"
$2dArrayWith5Columns[Ubound($2dArrayWith5Columns) -1][1] = "Last row Column 1"
$2dArrayWith5Columns[Ubound($2dArrayWith5Columns) -1][2] = "Last row Column 2"
$2dArrayWith5Columns[Ubound($2dArrayWith5Columns) -1][3] = "Last row Column 3"
$2dArrayWith5Columns[Ubound($2dArrayWith5Columns) -1][4] = "Last row Column 4"

_ArrayDisplay($2dArrayWith5Columns)

Share this post


Link to post
Share on other sites
dali4u

thx, i solve it like this:

#include <Array.au3>

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

$showEmptySections = 0

$sections = IniReadSectionNames($iniSource)

Dim $aINIContent[1][5] = [["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] Step 4

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

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

$activeLine = $aINIContent[0][0]

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

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

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

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

$aINIContent[$activeLine][4] = $contents[$j+3][1]

Next

EndIf

;_ArrayDisplay($contents)

EndFunc

disadvantage is that each entry MUST cantain 4 rows, otherwise it won't work,

but up to now it works fine and i'm able to build a nice GUI....

Share this post


Link to post
Share on other sites
ChrisL

disadvantage is that each entry MUST cantain 4 rows, otherwise it won't work,

To stop it crashing why don't you check for the correct number of entries first if there isn't 4 then either redim the section read to add blanks or skip the section completely :)

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  

×