Jump to content

Check the amount of parts to an array


Recommended Posts

I am trying to see if $Array[5] = "" or if it = something else, so this is what I have

if $Array[5] <> "" then

msgbox(0,"",$Array[5])

Else

Msgbox(0,"","Array Not Complete")

Endif

Whats wrong with it? lol :)

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

Try this?

If String($Array[5]) <> "" then
msgbox(0,"",$Array[5])
Else
Msgbox(0,"","Array Not Complete")
EndIf

Line -1:

Error: Subscript used with non-Array variable.

(BTW, the array is declared at the start of the file, and the IF statement is placed inside a function)

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

nvm

#include<Array.au3>

Dim $Array[1]

_ArrayAdd($Array, "1")

_ArrayAdd($Array, "2")

_ArrayAdd($Array, "3")

_ArrayAdd($Array, "4")

If $Array[5] Then

If String($Array[5]) <> "" Then

MsgBox(0,"",$Array[5])

Else

MsgBox(0,"","Array Not Complete")

EndIf

Else

MsgBox(0, "Error", "$Array[5] doesn't exist")

EndIf

Line 10 (File "C:\Documents and Settings\Elizabeth\Desktop\New AutoIt v3 Script.au3"):

If $Array[5] Then

If ^ ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

Ok try this; (my previous post was not tested, sorry, but this one is)

If Ubound($Array)-1 = 5 Then ;Checks for $Array[5]
    If $Array[5] <> "" Then
        MsgBox(0,"",$Array[5])
    Else
        MsgBox(0,"","Array Not Complete")
    EndIf
Else
    MsgBox(0, "Error", "$Array[5] doesn't exist")
EndIf

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

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