ptrex Posted May 30, 2006 Posted May 30, 2006 Hello, I am missing an Lbound() function in AutoIT. Is there an alternative arround ? Or could it be added over time ? Thanks Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
JSThePatriot Posted May 30, 2006 Posted May 30, 2006 Hello,I am missing an Lbound() function in AutoIT. Is there an alternative arround ?Or could it be added over time ?ThanksBased on the link I found for LBound() which is the opposite of UBound() I dont believe AutoIt needs an LBound() due to all array's starting at 0. The size of an array if I am not mistaken is UBound($array) + 1.http://www.csidata.com/custserv/onlinehelp...docs/vbs145.htmI may be speaking out of turn, but as I am pretty sure that AutoIt doesnt allow anything other than 0 for the Lower limit.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Moderators big_daddy Posted May 30, 2006 Moderators Posted May 30, 2006 Based on the link I found for LBound() which is the opposite of UBound() I dont believe AutoIt needs an LBound() due to all array's starting at 0. The size of an array if I am not mistaken is UBound($array) + 1. http://www.csidata.com/custserv/onlinehelp...docs/vbs145.htm I may be speaking out of turn, but as I am pretty sure that AutoIt doesnt allow anything other than 0 for the Lower limit. JSIt actually would be nice to be able to do something like this: ; The smallest available subscript of the array dimension $i = LBound($array) ; The upper limit of the array dimension $z = UBound($array) For $i To $z ; Do something Next
JSThePatriot Posted May 30, 2006 Posted May 30, 2006 It actually would be nice to be able to do something like this: ; The smallest available subscript of the array dimension $i = LBound($array) ; The upper limit of the array dimension $z = UBound($array) For $i To $z ; Do something NextoÝ÷ Ûú®¢×ºw^®ËZÜ!z·²¢æ«yÊ&x®· .Ùë(ëax,i¸y«"z·(uçâÅ«¢+Ø(ÀÌØíèôU ½Õ¹ ÀÌØíÉÉä¤()½ÈÀÌØí¤ô1 ½Õ¹ ÀÌØíÉÉä¤Q¼ÀÌØíèMÑÀÄ(í¼Í½µÑ¡¥¹ÕÍÕ°)9áÐ You are required for some reason to assign a value to the variable in the For...Next statement. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Valik Posted May 30, 2006 Posted May 30, 2006 I'm not seeing the point, really. But my question is, if the function is missing, why are you telling us, why aren't you writing a user-defined function to do it?
ptrex Posted May 30, 2006 Author Posted May 30, 2006 (edited) I'm not seeing the point, really. But my question is, if the function is missing, why are you telling us, why aren't you writing a user-defined function to do it?ValikIt' s not a big deal to write a UDF for it, but it's not consistant with the Ubound () is it ?Ubound is not a UDF or am I mistaken, so why should the other one be one ?Anyhow if you don't like the opposite of Ubound (), let it be for my part.But I am wondering there are that many functions and macro's available, why would this one hurt anyone ? Edited May 30, 2006 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Moderators SmOke_N Posted May 30, 2006 Moderators Posted May 30, 2006 (edited) I assumed after reading it on MSDN it was something like:Dim $Array[3] $Array[2] = 15 $Lbound1 = _Lbound($Array, 0) ConsoleWrite('Attempt 1' & @LF & 'Element ' & $Lbound1 & ' = ' & $Array[$Lbound1] & @LF) ; with making their own array, some use [0] as a value ;;; $aString = StringSplit('abcdefg', '') $Lbound2 = _Lbound($aString) ConsoleWrite('Attempt 2' & @LF & 'Element ' & $Lbound2 & ' = ' & $aString[$Lbound2] & @LF) ;;; Func _Lbound(ByRef $aArray, $iStart = 1) For $iCount = $iStart To UBound($aArray) - 1 If $aArray[$iCount] <> '' Then Return $iCount Next SetError(1) Return 0 EndFuncAm I off base here? Of course Return 0 could be an issue IMO. Edit: SetError(1) ... Edited May 30, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Valik Posted May 30, 2006 Posted May 30, 2006 Various random points:Larry is right, if the goal is return the first non-empty element, then it is not the opposite of UBound(). UBound() always returns the size of the array which can also be thought of as one past the last element.What constitutes empty? For a string "" could be empty or "EMPTY" could be empty or...What does it matter if the function is built-in or provided via a user-defined function? As long as the function does what it is supposed to, be happy.People will use LBound() wrong with arrays returned from functions (like StringSplit() versus arrays created manually. In the former case, the actual content starts at element 1 because element 0 is reserved for specifying the size of the array. In the latter case, the real content probably starts at element 0.There's no real need for AutoIt to have this function built in. For one thing, there are a lot of areas for contention over how the function should behave. It would be best if you just write a function to serve the purpose you need it for and call it good.
Moderators SmOke_N Posted May 30, 2006 Moderators Posted May 30, 2006 Various random points:Larry is right, if the goal is return the first non-empty element, then it is not the opposite of UBound(). UBound() always returns the size of the array which can also be thought of as one past the last element.What constitutes empty? For a string "" could be empty or "EMPTY" could be empty or...What does it matter if the function is built-in or provided via a user-defined function? As long as the function does what it is supposed to, be happy.People will use LBound() wrong with arrays returned from functions (like StringSplit() versus arrays created manually. In the former case, the actual content starts at element 1 because element 0 is reserved for specifying the size of the array. In the latter case, the real content probably starts at element 0.There's no real need for AutoIt to have this function built in. For one thing, there are a lot of areas for contention over how the function should behave. It would be best if you just write a function to serve the purpose you need it for and call it good.That was the concern I had for Return 0... I personally stay away from giving [0] a value with my made arrays, but it's not as easy to use unless you know that your elements start at 1 or 0 depending on the function you use (StringRegExp() could return [0] as a value as in example). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Wus Posted May 30, 2006 Posted May 30, 2006 If a function was called LBound then it should look like this func LBound( ByRef $aArray ) if( isArray($aArray) ) Then Return 0 else return -1 endfunc You want a _FindFirstElementNotEqualTo( $EmptyString ) but if you want that then you should make a _FindLastElementNotEqualTo( $EmptyString ) as well, then they'd both be UDF's.
ptrex Posted May 31, 2006 Author Posted May 31, 2006 (edited) Thanks all for the feedback.I don' t understand why you all make so much "fuss" about this Lbound function ?If it sounds like sloppy codingor I'm not seeing the point, really. Why do a lot of language have this function available ?VBS, VB(A), PHP, C#, C++, JScript, ASP, PLSQL, .Net, Java, ...But OK I know AutoIT is superior Maybe the developers of the other languages where not that clever. Who cares. If you think this is over the top, let it be and we can continue with our lives.I will call Bill Gates right away, to tell him to remove this "superfluous" function from the languages he is distributing. LOLPS; I' ve even seen that some languages have even "rBound". But don't panic I will start an other topic for this !? Edited May 31, 2006 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
tonedeaf Posted May 31, 2006 Posted May 31, 2006 Why do a lot of language have this function available ?VBS, VB(A), PHP, C#, C++, JScript, ASP, PLSQL, .Net, Java, ...The reason why other languages have a LBound() function is they allow you to define even the first element of the array. Eg: In VB you can define an array with Dim A(2 To 100)Where the array starts from 2 and using A(1) would generate an error.In such conditions, having a LBound function is useful.In AutoIt, an array always starts from 0 and as such a LBound() function is not required.
ptrex Posted May 31, 2006 Author Posted May 31, 2006 @tonedef Thanks for pointing this out. Maybe we should think of implementing an non zero based Array function ? Basically the reason I raised this topic, is that I am doing a lot of VB(A) and VBS conversions to AutoIT. And I always run into this Lbound function. Any Valik pointed out he is not interested, so I will have to do with what there is at the moment. CU all later. I have an other question that I want to rease. But I will start a new topic. Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Busti Posted June 3, 2006 Posted June 3, 2006 dim $array[30] $array[25] = "lool" now it starts at 25 other b4 are "" My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity
Valik Posted June 3, 2006 Posted June 3, 2006 dim $array[30] $array[25] = "lool" now it starts at 25 other b4 are ""No, the array starts at 0, the element[25] just happens to contain non-empty data. There is a difference.
Nutster Posted June 19, 2006 Posted June 19, 2006 (edited) I wrote the UBound function to give the size of array dimensions. UBound($array,0) will tell the number of dimensions (something that VB's UBound does not do). Because all arrays in AutoIt start with element 0, even if some people do not want to use the first element, I saw no point in creating LBound; it would always be returning 0.As for changing the array dimensioning to allow it to start at something other than 0, there are some non-insignificant performance and memory penalties in implementing that. Also, the array dimensioning routine would need a major rewrite to implement it. As a workaround, if you want to use only elements 20 to 40, then define elements 0-20 and subtract 20 from the elment number prior to referencing. I have plans on some other changes I would like to make to the array system after the next release, now that I have some time but I have some bugs fixes to do first. I do not expect LBound to be part of those changes.Edit: fox spelling errors. Edited June 22, 2006 by Nutster David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd...
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