Opened on Nov 15, 2009 at 2:53:07 PM
Closed on Nov 15, 2009 at 5:38:14 PM
Last modified on Nov 17, 2009 at 3:09:26 AM
#1298 closed Feature Request (Rejected)
Poor Behavious of UBound Function
| Reported by: | nitrogen | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | Cc: |
Description
For UBound function, it gives me an impression that it should return the UPPER BOUNDARY of an array, but it actually returns the SIZE of array instead.
For example, we loop an array using this
Dim $myArray[10]
For $r = 0 to UBound($myArray) - 1
$myArray[$r]=$r
Next
But if ubound really return the upper boundary, it should be
Dim $myArray[10]
For $r = 0 to UBound($myArray)
$myArray[$r]=$r
Next
In VB, UBound does return the upper boundary but NOT the size of array.
Thanks!
Attachments (0)
Change History (4)
comment:1 by , on Nov 15, 2009 at 4:00:02 PM
| Version: | 3.3.0.0 |
|---|
comment:2 by , on Nov 15, 2009 at 5:38:14 PM
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
The behavior of VB is stupid.
comment:3 by , on Nov 17, 2009 at 2:49:03 AM
Even I hate VB, I think VB behaves more logically correct.
UBound should return the Upper Index of an array instead of Upper Index + 1,
If you name UBound as ArraySize, then the current implementation is correct.
I am interested to see other admin's comment
comment:4 by , on Nov 17, 2009 at 3:09:26 AM
Actually, you're just plain wrong. Visual Basic and VBS both behave very much like AutoIt.
If you need to track the last used index then track it yourself. AutoIt cannot do that for you. No language can do it with 100% reliability to suit everyone. AutoIt, VB and VBS all have the correct behavior which is to report what the highest possible index is (keeping in mind the index needs offset by subtracting 1).

Automatic ticket cleanup.