Sign in to follow this  
Followers 0
Davarious

Array Assistance...

6 posts in this topic

Here is a quick background:

I have an INI file, section [backup] will contain values 1=Blah, 2=Blah etc for as many values as the user wishes.

I need to do the following with this,

Read the INI File until no values exist, so for example...

$i = 1
Do
    $Value IniRead("File.ini", "BACKUP", $i, "")
    $i += 1
    _ArrayAdd($aTest,$Value) 
Until $Value =""

Next I would want to do something like the following...

Do
    RunSomeCommand calling $aTest[$i]; I have not decided on this yet, but it is not important yet.
    $i -= 1
Until $i = -1; Doing negative 1 since Arrays start at 0.

Can anyone tell me if there is an easier way to do this, or confirm if I am on the right path?

Share this post


Link to post
Share on other sites



Check out UBound:

Dim $myArray[10][20]   ;element 0,0 to 9,19
$rows = UBound($myArray)
$cols = UBound($myArray, 2)
$dims = UBound($myArray, 0)

MsgBox(0, "The " & $dims & "-dimensional array has", _
    $rows & " rows, " & $cols & " columns")

;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)

Share this post


Link to post
Share on other sites

UBound!

You are my hero! Thats the kind of function I have been looking for.

Share this post


Link to post
Share on other sites

Why use IniRead only? Try IniReadSectionNames and IniReadSection instead.

Share this post


Link to post
Share on other sites

Why use IniRead only? Try IniReadSectionNames and IniReadSection instead.

To generate the array, I will do so. I just used that as a simple example to get the point across what I needed. The response for UBound saved me painful overthinking, as I did not know that function existed.

The key is I need that total value for the contents of an array, for use later in the script, when I start creating my backup file. The issue is that this script I am building is a universal script to use at over 50 client locations, with more than 3 methods of backup (some to a drive, some to a FTP server etc). And also due to the nature that different files contain different information at each client based on how they were configured prior to me being hired, this allows me to configure the backups based on an INI.

Share this post


Link to post
Share on other sites

Glad I could help :whistle:

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