Jump to content

Recommended Posts

Posted

Hi everyone

Simple question (I hope) I have a fixed size [5] 1d array and am pushing and removing values to/from it, when there is a value in it I perform another function with that value but if its empty I don't, simple as that.

How do I check it has something in it?

Posted

Dim $array[5] = [0,0,1,0,1]
$iArrayEmpty = ""
for $i = 0 to UBound($array) -1
    if $array[$i] then $iArrayEmpty &= $i & ","
next
if not $iArrayEmpty Then
    MsgBox(0,"","Array is empty")
Else
    $iArrayEmpty = Stringleft($iArrayEmpty,StringLen($iArrayEmpty)-1)
    MsgBox(0,"","Array contains values at position " & $iArrayEmpty)
endif

Dim $array[5] = [0,0,0,0,0]
$iArrayEmpty = ""
for $i = 0 to UBound($array) -1
    if $array[$i] then $iArrayEmpty &= $i & ","
next
if not $iArrayEmpty Then
    MsgBox(0,"","Array is empty")
Else
    $iArrayEmpty = Stringleft($iArrayEmpty,StringLen($iArrayEmpty)-1)
    MsgBox(0,"","Array contains values at position " & $iArrayEmpty)
endif

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...