Jump to content

Some General Questions On Arrays


Recommended Posts

yes well i was wondering if i could do something such as this:

if array[&var&]
then
SOME CODE

Could i do it like this or should i do something that has the same effect?

(i also noticed another topic i started is no longer with us, i was wondering what happened to it.)

Link to comment
Share on other sites

Sure, you can do that. Take a look at this example:

$array = StringSplit("1,2,3,4,5,6,7,8,9,10", ",");create a numbered array
For $a = 1 To 10;loop through the array
  If $array[$a] = 5 Then
    MsgBox(0, "", "Element " & $a & " is 5")
  Else
    MsgBox(0, "", "Element " & $a & " is not 5")
  EndIf
Next

As for your topic, it should still be here, but it's probably just older than 30 days. I think the default forum view only shows stuff in the last 30 days.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

How do I use Ubound in an array, and why should i use Ubound?

<{POST_SNAPBACK}>

UBound returns the number of elements in the array. It is important to note that this returns a number one higher than the index of the last element array.

Example: suppose you created an array by using Dim $array[3]

The last element of this array is $array[2], since the first element is $array[0]. To access this element using UBound, you can do: $array[uBound($array) - 1]. Note the minus one. That is important, since leaving it off will produce an error.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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