Jump to content

Do...Until problem inside a For...Next nest


Recommended Posts

I've been working on this simple problem way too long and need help. I don't know what I'm overlooking here that is causing one of two true statements to be ignored. If you change the array values you'll see that the problem seems to occur when the second element of the $avKb array is checked.

Also if there's a better way to accomplish what I'm trying to achive, please let me know in addition to why you believe my current code does work.

Many thanks!

; Input table has 9 entries; $avInput[9]
; Kb table has 2 entries; $avKb[2][6]
; need to have all 9 $avInput search against $avKb for possible matches
; and only the $avInput values not found in $avKb should be forwarded to
; the rest of the script.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#include<array.au3>

Dim $avInput[9] = ["Colors", "Men", "Women", "Cars", "Numbers", "Shapes", "Cities", "Ages", "Pets"]
Dim $avKb[2][6] = [["Shapes","Red","Orange","Yellow","Green","Blue"] , ["Cars","16","18","21","55","75"]]
Dim $i = 0, $j = 0, $KbResults, $ln, $m = 0, $n = 0, $c11, $r = 0

_ArrayDisplay($avInput)
_ArrayDisplay($avKb)

_Debug2(@ScriptLineNumber)
For $m = 0 To UBound($avInput) -1
    _Debug2(@ScriptLineNumber)
    Do
        _Debug2(@ScriptLineNumber)
        If $avInput[$m] = $avKb[$r][0] Then
            _Debug2(@ScriptLineNumber)
            $c11 = "match"
            ExitLoop
        Else
            _Debug2(@ScriptLineNumber)
            $c11 = "no-match"
        EndIf
        _Debug2(@ScriptLineNumber)
        $r += 1
        _Debug2(@ScriptLineNumber)
    Until $r = UBound($avKb) - 1
    _Debug2(@ScriptLineNumber)
    Switch $c11
        Case "match"
            _Debug2(@ScriptLineNumber)
            ;$KbResults = ""
            For $j = 1 To UBound($avKb) + 1
                _Debug2(@ScriptLineNumber)
                $KbResults &= $avKb[$n][$j] & " or "
                _Debug2(@ScriptLineNumber)
            Next
            _Debug2(@ScriptLineNumber)
            $KbResults = StringTrimRight($KbResults, StringLen(" or "))
            _Debug2(@ScriptLineNumber)
            MsgBox(0,"Match Found In KB", "Data set found in known list." & _
            @crlf & @crlf & $avInput[$m] & " has the following possible replacements" & _
            @CRLF & $KbResults)
            Dim $KbResults = "", $r = 0
            ;ContinueLoop
        Case "no-match"
            _Debug2(@ScriptLineNumber)              
            MsgBox(0,"Match Not In KB", $avInput[$m] & " needs to check against Character Map before creating entry in KB.")
            _Debug2(@ScriptLineNumber)
            $r = 0
            ContinueLoop
    EndSwitch
    _Debug2(@ScriptLineNumber)
Next
_Debug2(@ScriptLineNumber)
MsgBox(0,"Exit", "Finally this works!")


Func _Debug2($ln)
    MsgBox(0,"Debug Var", "Line: " & $ln & _
    @CRLF & "Input = " & $avInput[$m] & _
    @CRLF & "Testing against : " & $avKb[$r][0] & _
    @CRLF & "-------------------------------------------" & _
    @CRLF & "$m is = " & $m & " and Max = " & UBound($avInput, 1) - 1 & _
    @CRLF & "$r is = " & $r & " and Max = " & UBound($avKb) - 1  & _
    @CRLF & "$c11 is = " & $c11 & _ 
    @CRLF & "$j is = " & $j & " and Max = " & UBound($avKb) - 1 & _ 
    @CRLF & "$KbResults is = " & $KbResults)
EndFunc
Link to comment
Share on other sites

the error is here: Until $r = UBound($avKb) -1

It is not an obvious one (took me a little to find it) but in the actual form it won't check the second element (it will quit before checking: once $r=1 it will quit - e.g. after the first passing)

This will solve your problem: Until $r = UBound($avKb)

Cheers,

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

the error is here: Until $r = UBound($avKb) -1

It is not an obvious one (took me a little to find it) but in the actual form it won't check the second element (it will quit before checking: once $r=1 it will quit - e.g. after the first passing)

This will solve your problem: Until $r = UBound($avKb)

Cheers,

Thanks enaiman! Oh if only it were true. I have tried almost everything including this prior to posting this message. Please copy the code into SciTE and run the script. You'll clearly see what I'm talking about. I did however give you the benefit of the doubt and tried your suggestion and it results in an error and kills the script.

Help please, please, please.

Link to comment
Share on other sites

Can't get your code to run at all. _ArrayDisplay needs parameters and will not do 2d arrays at all. May be you are using different Array library.

Anyway, I can't find the bug but can suggest an easier way.

Since you seem to search only in column 0 you may want to keep all entries in a string with a separator like this:

$str_master = "|Shapes|Red|Orange|Yellow|Green|Blue|"

and use StringInStr

For $m = 0 To UBound($avInput) -1

If StringInStr($str_master, "|" & $avInput[$m] & "|") = 0 then

$c11 = "no-match"

Else

$c11 = "match"

EndIf

Next

This is just a suggestion but will simplify the code and probably will run faster since multi-d arrays are kind of slow in Autoit

Link to comment
Share on other sites

Thanks enaiman! Oh if only it were true. I have tried almost everything including this prior to posting this message. Please copy the code into SciTE and run the script. You'll clearly see what I'm talking about. I did however give you the benefit of the doubt and tried your suggestion and it results in an error and kills the script.

Help please, please, please.

The function is so... non-functional... that it's hard to see what you WANT it to do. This is the exact same script, with the distractions and unused stuff removed:

; Input table has 9 entries; $avInput[9]
; Kb table has 2 entries; $avKb[2][6]
; need to have all 9 $avInput search against $avKb for possible matches
; and only the $avInput values not found in $avKb should be forwarded to
; the rest of the script.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#include<array.au3>

Dim $avInput[9] = ["Colors", "Men", "Women", "Cars", "Numbers", "Shapes", "Cities", "Ages", "Pets"]
Dim $avKb[2][6] = [["Shapes", "Red", "Orange", "Yellow", "Green", "Blue"], ["Cars", "16", "18", "21", "55", "75"]]

_ArrayDisplay($avInput)
_ArrayDisplay($avKb)

For $m = 0 To UBound($avInput) - 1
    $c11 = "no-match"
    For $r = 0 To UBound($avKb) - 1
        If $avInput[$m] = $avKb[$r][0] Then
            $c11 = "match"
            ExitLoop
        EndIf
    Next
    
    If $c11 = "match" Then
        $KbResults = ""
        For $j = 1 To UBound($avKb) + 1
            $KbResults &= $avKb[0][$j] & " or "
        Next
        $KbResults = StringTrimRight($KbResults, StringLen(" or "))
        
        MsgBox(0, "Match Found In KB", "Data set found in known list." & _
                @CRLF & @CRLF & $avInput[$m] & " has the following possible replacements" & _
                @CRLF & $KbResults)
    Else
        MsgBox(0, "Match Not In KB", $avInput[$m] & " needs to check against Character Map before creating entry in KB.")
    EndIf
Next

MsgBox(0, "Exit", "Finally this works!")

Now, what was this supposed to do?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Unless I misunderstand the purpose of all this, in your Switch "match" case you really need to do Ubound on 2nd dimension, not 1st.

Also, list should be depending on matched row, not just 1st row, because this makes both Cars and Shapes return the same "Red or Orange or Yellow".

So based on the above by PsaltyDS, could it be...

#include<array.au3>

Dim $avInput[9] = ["Colors", "Men", "Women", "Cars", "Numbers", "Shapes", "Cities", "Ages", "Pets"]
Dim $avKb[2][6] = [["Shapes", "Red", "Orange", "Yellow", "Green", "Blue"], ["Cars", "16", "18", "21", "55", "75"]]

_ArrayDisplay($avInput)
_ArrayDisplay($avKb)

For $m = 0 To UBound($avInput) - 1
    $c11 = "no-match"
    For $r = 0 To UBound($avKb) - 1
        If $avInput[$m] = $avKb[$r][0] Then
            $c11 = "match"
            ExitLoop
        EndIf
    Next
    
    If $c11 = "match" Then
        $KbResults = ""
        For $j = 1 To UBound($avKb, 2) - 1
            $KbResults &= $avKb[$r][$j] & " or "
        Next
        $KbResults = StringTrimRight($KbResults, StringLen(" or "))
        
        MsgBox(0, "Match Found In KB", "Data set found in known list." & _
                @CRLF & @CRLF & $avInput[$m] & " has the following possible replacements" & _
                @CRLF & $KbResults)
    Else
        MsgBox(0, "Match Not In KB", $avInput[$m] & " needs to check against Character Map before creating entry in KB.")
    EndIf
Next

MsgBox(0, "Exit", "Finally this works!")
Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

The function is so... non-functional... that it's hard to see what you WANT it to do. This is the exact same script, with the distractions and unused stuff removed:

@PsaltyDS - LOL.. functional or non-functional is kind of a subjection statement don't you think :P. I only use that _Debug2() function to help me see what's going on so that I can try to understand and learn what I'm doing right or wrong. Remember I have no programming background and only recently, thanks to you and Paulie, have begun to understand arrays. As usual, your code worked like a charm; especially since you didn't know what it was suppose to do :)

Unless I misunderstand the purpose of all this, in your Switch "match" case you really need to do Ubound on 2nd dimension, not 1st.

Also, list should be depending on matched row, not just 1st row, because this makes both Cars and Shapes return the same "Red or Orange or Yellow".

@Siao - Thanks for helping me see another way of accomplishing my end goal! Your code worked like a champ and I now have two working sets of code that I can study.

@is8591 - Sorry the code didn't work for you as it did for me. I'm too new to be messing with stuff and I'm using the plain vanilla au3 v3.2.4.9 and SciTE4AU3 v1.74. Thanks for the alternative suggestion!

Once I get this little project finished I'll post it in Examples forum and ask those interested to help me streamline and learn a better coding practices. Many thanks again for everyone's response and suggestions! Another solved mystery by the good folks of the au3 community!

EDIT: Thanks to Siao's code (before he edited it :)) I was able to find the error in my original code! The mistake is a result of me trying many different things and leaving a small piece of older code in the mix. I knew this had to be a very simple answer, I just couldn't see the it looking straight at me. Changing the original code

FROM:

Switch $c11
    Case "match"
        For $j = 1 To UBound($avKb) + 1
            $KbResults &= $avKb[$n][$j] & " or "
        Next

Now for the million dollar question. Can someone explain to me how or why the following two lines of code act the same way?

  • For $j = 1 To UBound($avKb) + 1
  • For $j = 1 To UBound($avKb, 2) - 1
I'm asking this because I'm seeking to understand so I can learn the correct theory instead of just accepting "because". Thanks again! Edited by ssubirias3
Link to comment
Share on other sites

Now for the million dollar question. Can someone explain to me how or why the following two lines of code act the same way?

* For $j = 1 To UBound($avKb) + 1

* For $j = 1 To UBound($avKb, 2) - 1

I'm asking this because I'm seeking to understand so I can learn the correct theory instead of just accepting "because". Thanks again!

These two lines should not be acting the same unless your array is something like this: $array[5][5] (notice the numbers are the same!)

Lets say we have the array like this:

Dim $array[5][5]

The function UBound($array) is going to return 5. The function UBound($array, 2) is going to return 5 to.

Now if we had an array like this:

Dim $array[10][2]

The function UBound($array) will return 10, while the UBound($array,2) is going to return 2.

The 2 in "UBound($array,2)" is the dimension you want. In the second example the second dimension only has two element, consequently two is returned.

In the first example the first dimension and the dimension were the same your loop would be the same.

Does that help?

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Please copy the code into SciTE and run the script. You'll clearly see what I'm talking about. I did however give you the benefit of the doubt and tried your suggestion and it results in an error and kills the script.

Of course I did that and tested it without any error (what else I did though was to remove all debug lines prior to testing)

this was my test code:

; Input table has 9 entries; $avInput[9]
; Kb table has 2 entries; $avKb[2][6]
; need to have all 9 $avInput search against $avKb for possible matches
; and only the $avInput values not found in $avKb should be forwarded to
; the rest of the script.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#include<array.au3>

Dim $avInput[9] = ["Colors", "Men", "Women", "Cars", "Numbers", "Shapes", "Cities", "Ages", "Pets"]
Dim $avKb[2][6] = [["Shapes","Red","Orange","Yellow","Green","Blue"] , ["Cars","16","18","21","55","75"]]
Dim $i = 0, $j = 0, $KbResults, $ln, $m = 0, $n = 0, $c11, $r = 0

_ArrayDisplay($avInput)
_ArrayDisplay($avKb)


For $m = 0 To UBound($avInput) -1
    Do
        If $avInput[$m] = $avKb[$r][0] Then
            MsgBox(0, "match", $avInput[$m]&" = "&$avKb[$r][0])
            $c11 = "match"
            ExitLoop
        Else
            MsgBox(0, "NO match", $avInput[$m]&" = "&$avKb[$r][0])
            $c11 = "no-match"
        EndIf
        $r += 1
    Until $r = UBound($avKb)
    Switch $c11
        Case "match"
            ;$KbResults = ""
            For $j = 1 To UBound($avKb) + 1
                $KbResults &= $avKb[$n][$j] & " or "
            Next
            $KbResults = StringTrimRight($KbResults, StringLen(" or "))
            MsgBox(0,"Match Found In KB", "Data set found in known list." & _
            @crlf & @crlf & $avInput[$m] & " has the following possible replacements" & _
            @CRLF & $KbResults)
            Dim $KbResults = "", $r = 0
            ;ContinueLoop
        Case "no-match"   
            MsgBox(0,"Match Not In KB", $avInput[$m] & " needs to check against Character Map before creating entry in KB.")
            $r = 0
            ContinueLoop
    EndSwitch
Next
MsgBox(0,"Exit", "Finally this works!")

Prior to make the modification the only match found was "Shapes" but not "Cars" because your Do-Until used to loop only once (a While loop would have been better in that case).

Anyway - glad that your problem is solved - if we discuss it further it will be only to analize what it was and what it should have been :)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Now for the million dollar question. Can someone explain to me how or why the following two lines of code act the same way?

  • For $j = 1 To UBound($avKb) + 1
  • For $j = 1 To UBound($avKb, 2) - 1
I'm asking this because I'm seeking to understand so I can learn the correct theory instead of just accepting "because". Thanks again!
You declared the array with [2][6], so UBound($avKb) + 1 should return 3, and UBound($avKb, 2) - 1 should return 5. Now, if you use that number as an array reference like $avKb[$j][0] then you will get the exact same error either way because both 3 and 5 are too large. If you change the + to - and use two different variables you would get good nested loops to check every cell in the array for something:

For $j = 0 To Ubound($avKb) -1
      For $k = 0 To Ubound($avKb, 2) - 1
            MsgBox(64, "Value", "$avKb[" & $j & "][" & $k & "] = " & $avKb[$j][$k])
      Next
Next

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

These two lines should not be acting the same unless your array is something like this: $array[5][5] (notice the numbers are the same!)Thank you Piano_Man! Yes what you and PsaltyDS are explaining makes perfect sense to me as it should! However the two lines of code I'm asking about do in fact act the same way; producing the same expected result -- not errors. Using Siao's code and changing one from UBound($avKb) + 1 to UBound($avKb, 2) - 1, the end result is error free and exactly the same.

This leads me to believe that UBound($avKb) + 1 translates to UBound($avKb, 2) - 1, but I'm not clean how or why. Unless UBound($avKb) + 1 is telling au3 since no dimension was specified the + 1 says move to the next dimension. Kind of like UBound($avKb) is the same as UBound($avKb, 1) and by adding 1 to UBound($avKb) that's telling au3 to change UBound($avKb, 1) to UBound($avKb, 2)??? I'm guessing I'm wrong, but would really like someone to explain why the following has the same result when dealing with $avKb. Make the following changes to Siao's code and you'll see what I'm talking about. Honest I'm not crazy!

Change 1 to Siao's Code: FROM

#include<array.au3>
Dim $avInput[9] = ["Colors", "Men", "Women", "Cars", "Numbers", "Shapes", "Cities", "Ages", "Pets"]
Dim $avKb[2][6] = [["Shapes", "Red", "Orange", "Yellow", "Green", "Blue"], ["Cars", "16", "18", "21", "55", "75"]]oÝ÷ Ù3ºÚ"µÍÚ[ÛYIØ^K]LÉÝÂ[H   ÌÍØ][]ÎWHHÉ][ÝÐÛÛÜÉ][ÝË    ][ÝÓY[][ÝË  ][ÝÕÛÛY[][ÝË  ][ÝÐØÉ][ÝË    ][ÝÓ[XÉ][ÝË    ][ÝÔÚÉ][ÝË    ][ÝÐÚ]YÉ][ÝË  ][ÝÐYÙÉ][ÝË   ][ÝÔ]É][Ý×B[H  ÌÍØ]ØÍVÍHHÖÉ][ÝÔÚÉ][ÝË    ][ÝÔY ][ÝË  ][ÝÓÜ[ÙI][ÝË  ][ÝÖY[ÝÉ][ÝË  ][ÝÑÜY[][ÝË    ][ÝÐYI][Ý×HÉ][ÝÐØÉ][ÝË   ][ÝÌM][ÝË   ][ÝÌN ][ÝË  ][ÝÌI][ÝË   ][ÝÍMI][ÝË  ][ÝÍÍI][Ý×HÂÉ][ÝÓY[][ÝË  ][ÝÒI][ÝË   ][ÝÓZZÙI][ÝË   ][ÝÔØ[I][ÝË    ][ÝÔØ    ][ÝË  ][ÝÒÙZ]  ][Ý×HÉ][ÝÔ]É][ÝË    ][ÝÑÙÉ][ÝË    ][ÝÐØ]   ][ÝË  ][ÝÑÛÛÚ    ][ÝË  ][ÝÔÝ    ][ÝË  ][ÝÔYÉ][Ý×WoÝ÷ Ø(Z¶¶ý°*xTN1«­¢+Ø%ÀÌØíÄÄôÅÕ½ÐíµÑ ÅÕ½ÐìQ¡¸(ÀÌØí-IÍÕ±ÑÌôÅÕ½ÐìÅÕ½Ðì(½ÈÀÌØí¨ôÄQ¼U ½Õ¹ ÀÌØíÙ-°È¤´Ä(ÀÌØí-IÍÕ±Ñ̵ÀìôÀÌØíÙ-lÀÌØíÉulÀÌØí©tµÀìÅÕ½Ðì½ÈÅÕ½Ðì(9áÐoÝ÷ Ù3ºÚ"µÍY ÌÍØÌLHH ][ÝÛX]Ú  ][ÝÈ[ ÌÍÒØÝ[ÈH  ][ÝÉ][ÝÂÜ  ÌÍÚHHÈPÝ[
    ÌÍØ]ØH
ÈBÈÜ ÌÍÚHHÈPÝ[
    ÌÍØ]ØHHB    ÌÍÒØÝ[È   [ÏH    ÌÍØ]ØÉÌÍÜVÉÌÍÚH [È ][ÝÈÜ    ][ÝÂ^

Thanks again for everyone's patience with me and my quest for understanding.

Link to comment
Share on other sites

You're not luring me into that trap. Here's a demo that shows the results of Ubound() in all those cases:

#include<array.au3>
Dim $avInput[9] = ["Colors", "Men", "Women", "Cars", "Numbers", "Shapes", "Cities", "Ages", "Pets"]
_ArrayDisplay($avInput, "Debug: Ubound($avInput) = " & Ubound($avInput))

Dim $avKb[2][6] = [["Shapes", "Red", "Orange", "Yellow", "Green", "Blue"], ["Cars", "16", "18", "21", "55", "75"]]
_ArrayDisplay($avKb, "Debug: Ubound($avKb) = " & Ubound($avKb) & "  Ubound($avKb, 2) = " & Ubound($avKb, 2))

Dim $avKb[4][6] = [["Shapes","Red","Orange","Yellow","Green","Blue"] , ["Cars","16","18","21","55","75"] , _
["Men", "Harry", "Mike", "Sam", "Robert", "Keith"] , ["Pets", "Dog", "Cat", "Goldfish", "Parrot", "Pig"]]
_ArrayDisplay($avKb, "Debug: Ubound($avKb) = " & Ubound($avKb) & "  Ubound($avKb, 2) = " & Ubound($avKb, 2))

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

However the two lines of code I'm asking about do in fact act the same way; producing the same expected result -- not errors. Using Siao's code and changing one from UBound($avKb) + 1 to UBound($avKb, 2) - 1, the end result is error free and exactly the same.

They are not the same, and the result is not the same, period.

In your original example,

UBound($avKb) + 1 = 3

UBound($avKb, 2) - 1 = 5

After For $i = 1 to 3 loop, $KbResults = "Red or Orange or Yellow"

After For $i = 1 to 5 loop, $KbResults = "Red or Orange or Yellow or Green or Blue"

How is that the same.

"be smart, drink your wine"

Link to comment
Share on other sites

I am afraid I am having difficulty following this code at all.

I can't figure out whats not working if I don't know what the end result is supposed to look like.

What do you want the MsgBoxes to say? What is the logic behind this function?

What is this supposed to do?

Link to comment
Share on other sites

They are not the same, and the result is not the same, period.

In your original example,

UBound($avKb) + 1 = 3

UBound($avKb, 2) - 1 = 5

After For $i = 1 to 3 loop, $KbResults = "Red or Orange or Yellow"

After For $i = 1 to 5 loop, $KbResults = "Red or Orange or Yellow or Green or Blue"

How is that the same.

Great point Siao! And yes after playing with different sizes of the $avKb array I've learned that UBound($avKb, 2) - 1 is the correct code to retrieve all values in a particular index row (if that's what its called). Let me try and explain more of what I'm after and trying to do. In the example code I threw together the $avKb array. The real $avKb will contain information pulled in from a log file where entries may have 3 to 10 values. Despite UBound($avKb, 2) - 1 being the right code, it presents a new challenge for me. For example:

USING:

Dim $avKb[2][6] = [["Men", "Harry", "Mike", "Sam"] , ["Pets", "Dog"]]oÝ÷ ØRL@8V®¶­sdFÒb33c¶d¶%³EÕ³eÒÒµ²gV÷Cµ6W2gV÷C²ÂgV÷Cµ&VBgV÷C²ÂgV÷C´÷&ævRgV÷C²ÂgV÷CµVÆÆ÷rgV÷C²ÂgV÷C´w&VVâgV÷C²ÂgV÷C´&ÇVRgV÷CµÒ²gV÷C´6'2gV÷C²ÂgV÷C³bgV÷C²ÂgV÷C³gV÷C²ÂgV÷C³#gV÷C²ÂgV÷C³SRgV÷C²ÂgV÷C³sRgV÷CµÒÂð¥²gV÷C´ÖVâgV÷C²ÂgV÷C´''gV÷C²ÂgV÷C´Ö¶RgV÷C²ÂgV÷Cµ6ÒgV÷C²ÂgV÷Cµ&ö&W'BgV÷C²ÂgV÷C´¶VFgV÷CµÒ²gV÷CµWG2gV÷C²ÂgV÷C´FörgV÷C²ÂgV÷C´6BgV÷C²ÂgV÷C´vöÆFf6gV÷C²ÂgV÷Cµ'&÷BgV÷C²ÂgV÷CµrgV÷CµÕ

$KbResults will be "Harry or Mike or Sam or or " and "Dog or or or or "whereas UBound($avKb) + 1 would produce the desired output for MEN but not PETS. So now I'm thinking that perhaps I should stick with something like UBound($avKb) + $ColumnCount and have $ColumnCount = number of elements not counting the blank fields. But I'm not sure how to accomplish this just yet. Any suggestion are appreciated, and again thank you all for helping me better understand UBound!

Guess what I'm looking for is the right way so that $KbResults will result in the following when $avKb[4][6] = [["Shapes","Red","Orange","Yellow","Green","Blue"] , ["Cars","16","18"] ,

["Men", "Harry", "Mike", "Sam"] , ["Pets", "Dog"]]:

For .................. Returns

--------------------------------------------

Shapes ........... "Red or Orange or Yellow or Green or Blue"

Cars ................ "16 or 18"

Men ................. "Harry or Mike or Sam"

Pets ................ "Dog"

Edited by ssubirias3
Link to comment
Share on other sites

Then instead of

For $j = 1 To UBound($avKb, 2)-1
        $KbResults &= $avKb[$i][$j] & " or "
    NextƒoÝŠ÷ ÚëjëhŠ×6 For $j = 1 To UBound($avKb, 2)-1
        If $avKb[$i][$j] <> "" Then $KbResults &= $avKb[$i][$j] & " or "
    Next
Thank you Siao! Worked like a champ. Funny how things look so easy and obvious when its in front of you.
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...