Sign in to follow this  
Followers 0
amokoura

Ubound principle

12 posts in this topic

I know how Ubound works; it returns the size. But wouldn't it be more logical to have it return the upper bound, the last index, of the array?

Share this post


Link to post
Share on other sites



No that wouldn't be logical at all, think about it, it's like saying a function deisgned to count the chars in a string would'nt count the last char.

And even though you almost always have to use Ubound()-1 it's not that big of a deal.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

No that wouldn't be logical at all, think about it, it's like saying a function deisgned to count the chars in a string would'nt count the last char.

And even though you almost always have to use Ubound()-1 it's not that big of a deal.

In other languages Ubound returns the last index I guess. And the name also refers to "Upper Bound".

I think it isn't a very intuitive word for returning a size or length.

Share this post


Link to post
Share on other sites

In other languages Ubound returns the last index I guess. And the name also refers to "Upper Bound".

I think it isn't a very intuitive word for returning a size or length.

What languages are you referring to?

This has been requested in feature requests. I asked for a SizeOf or anything that hints at array size.

Share this post


Link to post
Share on other sites

In other languages Ubound returns the last index I guess. And the name also refers to "Upper Bound".

I think it isn't a very intuitive word for returning a size or length.

I agree on the last statement and it would indeed be better to call the function size() or sizeof().

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I agree on the last statement and it would indeed be better to call the function size() or sizeof().

Even an alias function would be nice so there would be Ubound() and SizeOf() (Or Length()).

Edited by weaponx

Share this post


Link to post
Share on other sites

What languages are you referring to?

This has been requested in feature requests. I asked for a SizeOf or anything that hints at array size.

I think he's referring to asp.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

What languages are you referring to?

Possibly in every other BASIC oriented language (VB, ASP etc.). Just googled "ubound" and the results convinced me.

Share this post


Link to post
Share on other sites

Possibly in every other BASIC oriented language (VB, ASP etc.). Just googled "ubound" and the results convinced me.

AutoIt decided to be different. I do not know why.

Share this post


Link to post
Share on other sites

AutoIt isn't as simple as it seems though. Yes it has basic syntax but it can be formed to be difficult - that sentence makes sense when I type it.

UBound - Upper bound

SizeOf - Size of array

Sounds good :D

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I see the OP's feature request was declined. I think it makes a lot more sense to have both Ubound and SizeOf. Valik's favorite word is "trivial", as in if there is a workaround using existing syntax then it is trivial to implement your own function.

See my request for a new Date UDF compatible FileGetTime() option:

http://svn.autoitscript.com/trac/ticket/160

New operators:

http://www.autoitscript.com/forum/index.ph...c=61322&hl=

I think at this point the developers are avoiding modification / addition to the AutoIt core, focus seems to be more on bugfixes, gui additions, and UDF additions. Additions to core syntax mean more documentation, more potential bugs, and changes to SciTE.

Additions to the core syntax would provide more robust and smaller code. I realize how trivial some functions are to implement but when they are written in native C++, speed is dramatically increased.

Edited by weaponx

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Yes, now it's officially rejected: http://svn.autoitscript.com/trac/ticket/224

Answer:

"It refers to the length when the array is initialized with an appropriate empty value. The behavior of UBound() is correct and will not be changed."

Actually that answer isn't quite clear to me. Could someone explain? :D

Edited by amokoura

Share this post


Link to post
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
Sign in to follow this  
Followers 0