#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 , 16 years ago
| Version: | 3.3.0.0 |
|---|
comment:2 by , 16 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
The behavior of VB is stupid.
comment:3 by , 16 years ago
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 , 16 years ago
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.