Sign in to follow this  
Followers 0
tAKTelapis

IniRead and _ArrayDisplay dont play nicely

4 posts in this topic

My function:

#include <array.au3>
$inifile = ("c:\test.ini")
$TestArray = IniReadSection($inifile, "test")
If @Error = 1 Then
    MsgBox(0, "Error", "Unable to read the ini file")
    Exit
EndIf
_ArrayDisplay($TestArray, "Teachers Already in system:")

Basically, what i am noticing is that when i read an ini file to an array with the "IniReadSection()" function, and then attempt to display it with the "_ArrayDisplay()" function, i get the following error:

$sMsg = $sMsg & "[" & $iCounter & "]    = " & StringStripCR($avArray[$iCounter]) & @CR 
$sMsg = $sMsg & "[" & $iCounter & "]    = " & StringStripCR(^ ERROR

some data to populate an ini file with:

[test]

test1=test1

test2=test2

test3=test3

test4=test4

Share this post


Link to post
Share on other sites



IniReadSection() returns a 2 dimension array but _ArrayDisplay() only handles 1 dimension.

:whistle:

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yarg.. ill bet if i had read the help file with more in more detail i would have noticed that.. wouldnt i. :whistle:

guess i will be writing a function to handle a multi-dimensional array then.. assuming one doesn't already exist?

*EDIT:

Well, was perusing the code of the array display function, and looked up the UBound function to see what it does.. and looksee what i found:

;Display $myArray's contents
$output = ""
For $r = 0 to UBound($myArray,1) - 1
    $output = $output & @LF
    For $c = 0 to UBound($myArray,2) - 1
        $output = $output & $myArray[$r][$c] & " "
    Next
Next
MsgBox(4096,"Array Contents", $output)

^ displays a 2 dimensional array :P and works 100% for my purposes all i had to do is change the $MyArray variable to my array. :D

thanks to its creator if you read it :lmao:

Edited by tAKTelapis

Share this post


Link to post
Share on other sites

Func _ArrayDisplay2D($aArray, $sTitle = 'Array Display 2Dim', $iBase = 1, $sToConsole = 0)
    If Not IsArray($aArray) Then Return SetError(1, 0, 0)
    Local $sHold = 'Dimension 1 Has:  ' & UBound($aArray, 1) -1 & ' Element(s)' & @LF & _
            'Dimension 2 Has:  ' & UBound($aArray, 2) - 1 & ' Element(s)' & @LF & @LF
    For $iCC = $iBase To UBound($aArray, 1) - 1
        For $xCC = 0 To UBound($aArray, 2) - 1
            $sHold &= '[' & $iCC & '][' & $xCC & ']  = ' & $aArray[$iCC][$xCC] & @LF
        Next
    Next
    If $sToConsole Then Return ConsoleWrite(@LF & $sHold)
    Return MsgBox(262144, $sTitle, StringTrimRight($sHold, 1))
EndFunc

http://www.autoitscript.com/forum/index.ph...st&p=302145


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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