AutoHotkey Community

It is currently May 27th, 2012, 1:22 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6
Author Message
 Post subject:
PostPosted: April 23rd, 2010, 1:14 am 
Offline

Joined: April 22nd, 2010, 6:58 pm
Posts: 9
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


Last edited by Rigel on April 26th, 2010, 9:55 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2010, 5:19 am 
Offline

Joined: October 3rd, 2007, 9:32 pm
Posts: 157
Location: UK
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:
Code:
Array1 := SA_Set(Array1, "Value", 1, 0)
Array2 := SA_Set(Array2, "Value", 2, 0)
msgbox %Array1%`n%Array2%

produces:
Code:
---------------------------
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.
Code:
Array := SA_Set(Array, "Value1", 1, "+1", "name")
Array := SA_Set(Array, "Value2", "name", 0)
msgbox %Array%

produces
Code:
---------------------------
test.ahk
---------------------------
Value2
---------------------------
OK   
---------------------------

Additionally, although the recognition of names appears to be case sensitive, specifying names appears not to be case sensitive since
Code:
Array := SA_Set(Array, "Value1", 1, "+1", "name")
Array := SA_Set(Array, "Value2", "name", 0, "NAME")
msgbox %Array%

still gives me
Code:
---------------------------
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,
Code:
Loop 3
   Array := SA_Set(Array, "Needle", A_Index, 0)
msgbox % Array "`n" SA_FindCnt(Array, "Needle")

returns
Code:
---------------------------
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
Code:
ele1ele2 ... eleN ; or
ele1ele2 ... eleN

otherwise 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.

########################################################
Code:
; !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
Quote:
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=""] )

which initially gave me a fair bit of confusion.

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
Code:
Array := SA_Set(Array, "Value1", 1)
Loop 3
   Array := SA_Set(Array, "Value2", 2)
MsgBox %Array%

produced
Code:
---------------------------
test.ahk
---------------------------
123
---------------------------
OK   
---------------------------

although this is just down to personal intuition.


Thanks


AHK v1.0.48.5


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2010, 4:41 pm 
Offline

Joined: March 27th, 2008, 2:14 pm
Posts: 700
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,"|")

_________________
Scripts - License


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2010, 5:17 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
@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.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2010, 5:40 pm 
Offline

Joined: March 27th, 2008, 2:14 pm
Posts: 700
hugov: yes, the documentation for this script has always been poor at best. That is something else I'm working on.

_________________
Scripts - License


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2010, 6:37 pm 
Offline

Joined: March 27th, 2008, 2:14 pm
Posts: 700
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.

_________________
Scripts - License


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2011, 10:21 am 
Offline

Joined: December 9th, 2009, 2:26 pm
Posts: 2
The download SimpleArray.ahk contains some strange character when open with notepad, and can not work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2011, 10:38 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.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Bon and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group