Jump to content

IniRead and _ArrayDisplay dont play nicely


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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

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.

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