jtrout 0 Posted June 26, 2007 Share Posted June 26, 2007 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 post Share on other sites
Leighwyn 0 Posted June 26, 2007 Share Posted June 26, 2007 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 post Share on other sites
jtrout 0 Posted June 26, 2007 Author Share Posted June 26, 2007 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 post Share on other sites
Leighwyn 0 Posted June 26, 2007 Share Posted June 26, 2007 (edited) 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 June 26, 2007 by Leighwyn Link to post Share on other sites
Valuater 135 Posted June 26, 2007 Share Posted June 26, 2007 ... like if the array had 0 - 5 I need to know is 6. ..How would I get that? $Servers[0] or Ubound($Servers) 8) Link to post Share on other sites
jtrout 0 Posted June 26, 2007 Author Share Posted June 26, 2007 DUH! Thank you! $Servers[0] or Ubound($Servers) 8) Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now