jmichae3 Posted February 15, 2014 Posted February 15, 2014 hi. the array-related functions don't quite match each other when it comes to [0] like stringsplit() whicdh is 1-based and strings which are 1-based and _Array which is always 0-based, and dimensioning the array, or a different array type should have been developed that can work with StringSplit() and the [added?] _Array functions with more stringsplit() compatible definition about array size (using [0]). or something. need more compatibility. there also needs to be a way to mass-initialize an array in the same compatible way without having to resort to Dim $arr=StringSplit("1,2,3,4",","),$i for $i=1 to $arr[0] $arr[$i]=int($arr[$i]) next when it would be easier to do it C++ initializer_list style like Dim $arr={1,2,3,4} ;would be more convenient, especially for multiline if didn't require _ due to comma or Dim $arr1=_ArrayNew(true, 1, 2, 3, 4) ;1st arg value true should cause $arr1[0] to be the number of elements, otherwise, will be 1st value in list, which is 1 Dim $arr2=_ArrayNew(true,"abc","def") ;number of args should make no difference, 2 or 200 I don't see anything in the documentation on this kind of feature, and I desperately need it.. Boolean: there needs to be string to bool and bool to string conversion functions, as well as StringIsBool(), maybe you prefer to call it Boolean like VB. it should use case-insensitive string comparison to check if the string is "true" or "false" and if it's neither, return failure and/or throw set an error. $varargs: functions with variable number of arguments would also be handy if it's not already there. where this comes in handy is doing sprintf, vsprintf, printf or format type of statements, making an _Array function for initizliaing an array. I was looking at the way teh language handles variable arguments, and it's pretty fixed, not variable. could a more variable method be made that allows for byref variables that are not optional, and optional arguments that can be treated as byref, using something like varargs or some special variable (how about $varargs) that makes one argument the varargs variable and [0] the number of elements? VB has I think provisions for a variable number of arguments if you are using that as a ruler. I could look it up if you are interested to find out. the manuals are online. Example: func somefunc(byref $arr, $str, $someint, byref $varargs) if ($varargs[0]>=2) then $varargs[2] = "somestring" ;pass data back endif for $i=1 to $varargs[0] $arr[$i] = $str & $varargs[$i] & $someint next endfunc I need to know a consistent and easy way to know the array size at any given time, and arrays and strings are inconsistent throughout the language, so that code requires extra hard thinking to engineer and to do language conversions. a couple of funcs are misnamed and are misleading actually. _ArrayPush() is not a push, but would more accurately be called _ArrayShift(). _ArrayAdd() is well-named, but should be aliased as _ArrayPush(). seeing the functions misnamed confused me at first. nobody needs that when they are trying to get work done, wastes precious time. C++ has some nice functions for stack and deque stuff, they are: push_front(byref $arr, $varargs, $index=1), push_back(byref $arr, $varargs), pop_front($index=1) which temporarily saves the element at $index, deletes the element and returns the saved value, pop_back() which temporarily saves and deletes the last element and returns the saved value. however what could be made better with c++ is pop functions could return the element of the array from front (first element or at given position). or back (last element). front_top($index=1) which returns element at index, back_top() which returns the last element. are classes and easier structures coming to this language at some point? woiuld be really nice to OOPify my code when needed. easier structures would be very very nice.
jmichae3 Posted February 15, 2014 Author Posted February 15, 2014 (edited) Boolean assignment and Boolean expression assignment: btw, Boolean array init as it is now is also not easy. should be a 1-liner or optionally a multiline array init: #include <Array.au3> Dim $arr=StringSplit("true,false,false,true",","),$i for $i=1 to $arr[0] $arr[$i]=Bool($arr[$i]) next _ArrayDisplay($arr) Edited February 15, 2014 by jmichae3
jmichae3 Posted February 15, 2014 Author Posted February 15, 2014 (edited) add this to your basic functions: func Bool($s) if ("true"==StringLower($s)) then return true elseif ("false"==StringLower($s)) then return false elseif (true=$s) then return true elseif (false"=$s) then return false elseif ($s) then return true elseif (not $s) then return false else ;set error here return 0; endif EndFunc func StringIsBool($s) return ("true"==StringLower($s) or "false"==StringLower($s)) endfunc Edited February 15, 2014 by jmichae3
Moderators Melba23 Posted February 15, 2014 Moderators Posted February 15, 2014 jmichae3,Any more complaints? I have just looked back through your posting history for the past few years and apart from this thread where you blatantly ignored the Forum rules, you have only posted to complain about the language and how it does not meet your expectations and differsin some respects from other languages you know. I do wonder why you keep using AutoIt at all seeing it causes you so much grief. M23 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
Werty Posted February 15, 2014 Posted February 15, 2014 Atleast it's a long post and not just "this sucks", I see it as constructive critisism. People talk differently, and he may not mean it as bad as you hear it. Some guy's script + some other guy's script = my script!
jchd Posted February 15, 2014 Posted February 15, 2014 jmichae3, Also if one start examining your prose and attempted examples, one wonder which language you're actually familiar with. Feel free to implement your own language. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
jmichae3 Posted February 15, 2014 Author Posted February 15, 2014 Func push_front(byref $arr, $val, $index=1) $arr[0]+=1 ;assume [0] is number of elements (array size) _ArrayInsert($arr, $index, $val) EndFunc Func push_back(byref $arr, $val) $arr[0]+=1 ;assume [0] is number of elements (array size) _ArrayAdd($arr, $val) EndFunc Func pop_front(byref $arr, $index=1) $arr[0]-=1 ;assume [0] is number of elements (array size) local $temp=$arr[$index] _ArrayDelete($arr, $index) return $temp EndFunc Func pop_back(byref $arr) $arr[0]-=1 ;assume [0] is number of elements (array size) local $temp=$arr[$arr[0]] _ArrayDelete($arr, $arr[0]) return $temp EndFunc
jmichae3 Posted February 15, 2014 Author Posted February 15, 2014 I saw some missing language pieces and was trying to fill them in. I was trying to help by at least adding some functions. wasn't trying to offend anyone (looks like I have by submitting patches). as far as writing my own language, I haven't written code for a syntax tree in 20 years, so it's out of my league without a another class, and those are hard to come by when you have already gone though it. books just aren't quite good enough to explain the whole thing. :-/ well, I like improving my own code, as long as some functions don't get really huge and nearly unmanageable. don't know about other folks. hey - free code. go for it. if it's only one guy maintaining the code that can be rough on a guy's head when code gets to a certain size - wrapping your brain around 1M LOC is hard. and sometimes, looking at other people's code is hard too. but I digress.
BrewManNH Posted February 15, 2014 Posted February 15, 2014 Most languages these days use zero based arrays, a lot of older languages used 1 based. So, at least AutoIt is consistent in that it matches today's languages. As to strings being 1 or zero based, the results are all over the place for today's languages as there's no real consistency on that. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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