Jump to content

_Array to tell the last element number?


Recommended Posts

I'm looking at all the last element number for an array so that way I can check it against an array from a file.

CODE

_FileReadToArray("My.txt", $Servers)

$newdrives = _ArrayCreate("TEMP")

For $x = 1 To $Servers[0]

$Driveletter = DriveMapAdd("*", $path, 0, $user, $password)

If $Driveletter = "" Then

MsgBox(0, "Error", "Error while mapping the drive to " & $Servers[$x] & "." & @CRLF & @error)

Else

_ArrayInsert($newdrives, $x, $Driveletter & "," & $Servers[$x])

EndIf

Next

_ArrayDelete($newdrives, 0)

If $Servers[0] = **WHAT DO I PUT HERE?** Then

msgbox(0,"TEST","YEP they are the same.")

Else

msgbox(0,"TEST","Nope they are not the same.")

Endif

Link to comment
Share on other sites

Well that gave me what was in the last element but I need to know what the numeric value of that numbered element is. like if the array had 0 - 5 I need to know is 6. How would I get that?

You can use Ubound($yourarray)-1 to get the array size, so that...

$lastelement = $yourarray[Ubound($yourarray)-1]

that should get you what you want.

Link to comment
Share on other sites

Well that gave me what was in the last element but I need to know what the numeric value of that numbered element is. like if the array had 0 - 5 I need to know is 6. How would I get that?

If you just wanted to know the array size, you would do

$size = Ubound($yourarray)-1
Edited by Leighwyn
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...