Modify

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#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 Changed 15 years ago by TicketCleanup

  • Version 3.3.0.0 deleted

Automatic ticket cleanup.

comment:2 Changed 15 years ago by Valik

  • Resolution set to Rejected
  • Status changed from new to closed

The behavior of VB is stupid.

comment:3 Changed 15 years ago by nitrogen

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 Changed 15 years ago by Valik

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

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.