czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) @JohnOne I think I'm not wording this very well. There is no inch (number) zero on a ruler, but there is an element zero in an array. The terms 'upper and lower bounds' make perfect sense on a ruler.EditBounds are not elements (nor inches): they are (by definition) boundaries. Edited December 12, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 12, 2015 Moderators Share Posted December 12, 2015 If I may,I can see 2 uses for such a function:Getting the number of elements in an array so that other variables might be sized accordingly.Getting the top index of the array - which is what the VBasic version of the function does.As AutoIt uses 0-based arrays these 2 values are not the same, with the first always being one more than the second. So there was a choice to be made (by Valik I believe) when the function was added to AutoIt:; What we do now Local $aNewArray[UBound($aOldArray)] For $i = 0 To UBound($aOldArray) - 1or; What might have happened Local $aNewArray[UBound($aOldArray) + 1] For $i = 0 To UBound($aOldArray)I see pros and cons in both approaches - but I am now so used to the way we have to do it. Personally I feel the function is wrongly named, but as the return value is quite specifically described in the Help file I see no problem with what it actually means.M23 TheDcoder 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
TheDcoder Posted December 12, 2015 Share Posted December 12, 2015 @Melba23 I feel the same way! I just can't put it in my wordsThanks for the explanation EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) I think the function is correctly named:Local $aRuler[12] ; Upper bound = 12 For $i = 0 To Ubound($aRuler) -1 ; final entry $aRuler[$i] = "inch " & ($i +1) ; the data represents a length value (in one dimensional space) with a start point and an end point Next Edited December 12, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Author Share Posted December 12, 2015 One use, for creating an array, the same size as another. Cheers M23 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Author Share Posted December 12, 2015 I think the function is correctly named:Local $aRuler[12] ; Upper bound = 12 For $i = 0 To Ubound($aRuler) -1 ; final entry $aRuler[$i] = "inch " & ($i +1) ; the data represents a length value (in one dimensional space) with a start point and an end point Next By your logic, -1 should be the lower bound of an array. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) Well bounds normally apply to limits, and not the information between them, so I disagree. A ruler is a perfect analogy. There are 13 callibrations on a 12 inch ruler (numbered 0 to 12). The elements of the array are like the inches of a ruler. Edited December 12, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Author Share Posted December 12, 2015 So you agree that 0 is not the lower bound of an array, since element 0 is information in it? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) No! 0 is the element enumeration convention being used here. The lower bound is still 0. The element value (also) encompasses all values elements between 0 and 1 (for example half an inch on my ruler). There is no such thing as half an array element though, but other than that the description fits perfectly as far as upper and lower bounds are concerned. Edited December 12, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Author Share Posted December 12, 2015 So if we're talking in box logic, 9 is the logical upper bound of a 10 element array if 0 is the lower bound. After 9 some imaginary boundary which counts for nothing is end of it, not 10. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) lower bound = 0 internal boundary = 1 upper bound = 2 | ....... element 0 ........ | ........ element 1 ........ | [0] [1] [2] <<< boundaries Edited December 12, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Author Share Posted December 12, 2015 So what we are getting the information for when looping through an array, if the units we use is the boundary and and not the element?That shows that we get the element immediately to the right of the boundary, so the final usable boundary in that representation is 1. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) That shows that we get the element immediately to the right of the boundary, so the final usable boundary in that representation is 1.Yep exactly that! Ubound means upper boundary - and not the final index number. This is not a misnomer. Edited December 12, 2015 by czardas JohnOne 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Author Share Posted December 12, 2015 I see, as I suspected. We'll have to agree to differ though, because I think that in the context of scripting, that is plain stupid, since there is no real separator between memory addresses, I believe the boundaries ought to be the first and last indices on an array. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) Most containers have more than one side, otherwise (in the real world) everything would simply just spill out. The term comes the upper limits of a range - everything within the range is less than this limit (both by definition and by convention) since the limit itself is not part of the container (it is the edge of the container). Change that and the the terminology 'upper bound' would no longer be applicable.Having said this, I understand that in other situations the upper bound may be reachable, and that the term is perhaps used rather loosely in some cases. Edited December 14, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Author Share Posted December 12, 2015 Lets wrongly agree for a second that an autoit variant is 4 bytes long.The first address of an 4 element "array" of those variants is 200, the next is 204, the next 208 and the last is 212.There is no 216 to mark the end of it, and in fact a container might be spread across non sequential addresses and if they had boundaries would be more than 5. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted December 12, 2015 Share Posted December 12, 2015 czardas, you are rationalizing. Again :P.Anyway, JohnOne is right, 100%. AutoIt is probably the only language in the world that reports Ubound() like that. VBS uses JohnOne's logic, C# also.So, what now? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) I'm more concerned with the definition of the word than how it is implemented. It really means a limit which you cannot go beyond, but in terms of an array (in AutoIt), it cannot be associated with any element existing within the array. Edited December 12, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted December 12, 2015 Share Posted December 12, 2015 (edited) czardas, you are rationalizing. Again :P.Anyway, JohnOne is right, 100%. AutoIt is probably the only language in the world that reports Ubound() like that. VBS uses JohnOne's logic, C# also.So, what now?Thanks trancexx. I looked at VB and it gave me this: https://msdn.microsoft.com/en-us/library/fhx59d0t(v=vs.84).aspxLook at the code and compare it to the description: there's something wrong on that page (I thought it was the description). Anyway I asked earlier if anyone did this - so now you say they do.Dim A(100,5,4) UBound(A, 1) ' returns 100...Returns the largest available subscript for the indicated dimension of an array.Contradiction? Edited December 12, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
trancexx Posted December 12, 2015 Share Posted December 12, 2015 (edited) Thanks trancexx. I looked at VB and it gave me this: https://msdn.microsoft.com/en-us/library/fhx59d0t(v=vs.84).aspxLook at the code and compare it to the description: there's something wrong on that page (I thought it was the description). Anyway I asked earlier if anyone did this - so now you say they do.Nope, everything is right there. Free your mind out of AutoIt and reread again.VB uses this syntax to declare array:Dim Arr(100)...but that's shorter for:Dim Arr(0 To 100)Which means "Create array which first index is 0 and last is 100". How many elements are there? Edited December 12, 2015 by trancexx czardas and iamtheky 2 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
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