edit: Thanks for your support, I made some suggestion but now I implement my own arrays script totally different from SimpleArray. However SimpleArray is a great script.
Bye
[lib] SimpleArray - short & fast string array - v3.5
Started by
infogulch
, Aug 25 2008 04:24 AM
82 replies to this topic
#76
-
Posted 23 April 2010 - 12:14 AM
Thanks infogulch for the library.
However, it's a bit problematic setting a second element without a first, as the first delimiter is removed and the array is reduced by the first (empty) element:
########################################################
Also, it seems that overwriting with named indexes is a bit flaky as I find I end up losing the name despite not specifying GiveName.
########################################################
I have also found that the _Find... functions do not take into account named indices, such that an element with name "Name" and value "Needle" (stored as "Name:Needle") does not constitute a whole match for the needle "Needle". Additionally,
Perhaps it may be worthwhile to use the delimiter to denote elements instead, so that every element is preceded/followed by "", i.e., store [ele1, ele2, ... , eleN] as
########################################################
Also, since most other languages overwrites elements of the array by default so that Array[j] := "Value" sets the j'th element to "Value", I found it a little counter-intuitive that by default the equivalent in SA, SA_Set(Array, "Value", j), puts it j elements off the end of the array by default. Indeed, the first time I tried creating an array of [1,2,3] (using AHKA notation), I was surprised to find that
Thanks
AHK v1.0.48.5
However, it's a bit problematic setting a second element without a first, as the first delimiter is removed and the array is reduced by the first (empty) element:
Array1 := SA_Set(Array1, "Value", 1, 0) Array2 := SA_Set(Array2, "Value", 2, 0) msgbox %Array1%`n%Array2%produces:
--------------------------- test.ahk --------------------------- Value Value --------------------------- OK ---------------------------
########################################################
Also, it seems that overwriting with named indexes is a bit flaky as I find I end up losing the name despite not specifying GiveName.
Array := SA_Set(Array, "Value1", 1, "+1", "name") Array := SA_Set(Array, "Value2", "name", 0) msgbox %Array%produces
--------------------------- test.ahk --------------------------- Value2 --------------------------- OK ---------------------------Additionally, although the recognition of names appears to be case sensitive, specifying names appears not to be case sensitive since
Array := SA_Set(Array, "Value1", 1, "+1", "name") Array := SA_Set(Array, "Value2", "name", 0, "NAME") msgbox %Array%still gives me
--------------------------- test.ahk --------------------------- Value2 --------------------------- OK ---------------------------
########################################################
I have also found that the _Find... functions do not take into account named indices, such that an element with name "Name" and value "Needle" (stored as "Name:Needle") does not constitute a whole match for the needle "Needle". Additionally,
Loop 3 Array := SA_Set(Array, "Needle", A_Index, 0) msgbox % Array "`n" SA_FindCnt(Array, "Needle")returns
--------------------------- test.ahk --------------------------- NeedleNeedleNeedle 2 --------------------------- OK ---------------------------since it appears that the find is based on matching the needle preceded by the delimiter. However, the first element is never preceded by a delimiter.
Perhaps it may be worthwhile to use the delimiter to denote elements instead, so that every element is preceded/followed by "", i.e., store [ele1, ele2, ... , eleN] as
ele1ele2 ... eleN ; or ele1ele2 ... eleNotherwise you will keep having to find various ways to account for the first element separately (i.e. having to change counts by +/-1 or have to check the last item separately in the SA_FindCnt() etc.), which is just a constant pain to do, and just requires more lines of code and leaves space for bugs.
########################################################
; !Important Note: ; ! The nIdx in SA_Set and Idx in SA_Set_ now only accept names or indexes ; ! and the "add to end + option" is now in the opt param ... SA_Set( Array, Val, nIdx="1", opt="+1", giveName="" )Finally, it might be a good idea to update this to the main post as it still says
which initially gave me a fair bit of confusion.Number Index: (param name Idx may only be a number)
If you want to add a value at the end of the array with SA_Set() use '+' as the first character and the number following will be counted as an offset from the end of the array. This allows you to add it arbitrarily farther than the end. (Note that the default index param is '+1' so you can add it to the end without specifying a number yourself)
...
SA_Set( Array, Val, [nIdx="+1", Insert=false, giveName=""] )
Also, since most other languages overwrites elements of the array by default so that Array[j] := "Value" sets the j'th element to "Value", I found it a little counter-intuitive that by default the equivalent in SA, SA_Set(Array, "Value", j), puts it j elements off the end of the array by default. Indeed, the first time I tried creating an array of [1,2,3] (using AHKA notation), I was surprised to find that
Array := SA_Set(Array, "Value1", 1) Loop 3 Array := SA_Set(Array, "Value2", 2) MsgBox %Array%produced
--------------------------- test.ahk --------------------------- 123 --------------------------- OK ---------------------------although this is just down to personal intuition.
Thanks
AHK v1.0.48.5
#77
-
Posted 22 December 2010 - 04:19 AM
Wow, thank you tuna for your time spent on this, I really appreciate it and will check these things out.
I've been working on the next version for some time now but haven't released it. During development it got to the point where when I fixed one thing it started breaking another thing, so I implemented a bunch of unit tests, which is probably the best thing I've done with this library so far. Among other things I greatly simplified calling the set function, as it was getting out of hand.
If you like, pm me and I'll get you a copy of the current beta (which I will probably bump to v4.0). Currently it only fails one of the SA_Trim unit tests and otherwise works fine.
By the way, the raw arrays are not intended to be viewed directly. Instead, you should use the SA_Join function to view them (such as in a messagebox). It also helps in the forum because the forum doesn't properly display the delimiter character and it is confusing when trying to read your bug reports. For example, SA_Join(Array1,"|")
I've been working on the next version for some time now but haven't released it. During development it got to the point where when I fixed one thing it started breaking another thing, so I implemented a bunch of unit tests, which is probably the best thing I've done with this library so far. Among other things I greatly simplified calling the set function, as it was getting out of hand.
If you like, pm me and I'll get you a copy of the current beta (which I will probably bump to v4.0). Currently it only fails one of the SA_Trim unit tests and otherwise works fine.
By the way, the raw arrays are not intended to be viewed directly. Instead, you should use the SA_Join function to view them (such as in a messagebox). It also helps in the forum because the forum doesn't properly display the delimiter character and it is confusing when trying to read your bug reports. For example, SA_Join(Array1,"|")
#78
-
Posted 28 December 2010 - 03:41 PM
@infogulch: good to hear you are still working on it. As requested a number of times in this thread and ask for help, some documentation with examples would be appreciated by many.
#79
-
Posted 28 December 2010 - 04:17 PM
hugov: yes, the documentation for this script has always been poor at best. That is something else I'm working on.
#80
-
Posted 28 December 2010 - 04:40 PM
Ok, so here's a beta version for those who would like to test it: SimpleArray-v3.6.ahk
The biggest change is the revamped Set function. Docs: SimpleArray-Docs-v3.6.txt
The following functions are either known to be broken or are probably broken: Unique, Shift, Swap, ConvertPsuedo, ConvertDelimited, and Join
I still need to create unit tests for the above functions, but the functions Set, Get, Del, Trim, Len, Find, FindCnt, and Sort work perfectly afaik.
If you find a bug with the (purportedly) working functions, please please send me a condensed version of what reproduces the bug and I will fix it and add a unit test to make sure it doesn't happen again.
The biggest change is the revamped Set function. Docs: SimpleArray-Docs-v3.6.txt
The following functions are either known to be broken or are probably broken: Unique, Shift, Swap, ConvertPsuedo, ConvertDelimited, and Join
I still need to create unit tests for the above functions, but the functions Set, Get, Del, Trim, Len, Find, FindCnt, and Sort work perfectly afaik.
If you find a bug with the (purportedly) working functions, please please send me a condensed version of what reproduces the bug and I will fix it and add a unit test to make sure it doesn't happen again.
#81
-
Posted 31 December 2010 - 05:37 PM
The download SimpleArray.ahk contains some strange character when open with notepad, and can not work.
#82
-
Posted 14 October 2011 - 09:21 AM
That is on purpose, those "strange" characters are asc 5 & 7 if I recall correctly, they are used as delimiters in the array.
Note that you can use real arrays and objects with AutoHotkey_l and that there are a number of array libraries posted here which should be easier to use. Simple Arrays is meant mostly for use with AutoHotkey basic, so it is recommended to download the latest AutoHotkey via the download page.
Note that you can use real arrays and objects with AutoHotkey_l and that there are a number of array libraries posted here which should be easier to use. Simple Arrays is meant mostly for use with AutoHotkey basic, so it is recommended to download the latest AutoHotkey via the download page.
#83
-
Posted 14 October 2011 - 09:38 AM