AutoHotkey Community

It is currently May 24th, 2012, 9:19 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 97 posts ]  Go to page 1, 2, 3, 4, 5 ... 7  Next
Author Message
PostPosted: December 13th, 2006, 7:26 am 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
Downloads
Latest Version : 6.00 (Build 2008:0730:1530)
Warning! Version 6.00 is NOT compatible with previous versions!
Quote:
Download (v6.00) @ Location 1 : AHKA AHK File
Download (v5.42) @ Location 1 : AHKArray AHK File
Download (v5.41) @ Location 1 : AHKArray AHK File
Download (v5.39) @ Location 1 : AHKArray AHK File
Download (v5.38) @ Location 1 : AHKArray AHK File
Download (v5.37) @ Location 1 : AHKArray AHK File
Download (v5.23) @ Location 1 : AHKArray AHK File


Bug Reports & License
Please send all bug reports, comments, suggestions, etc to olegbl@gmail.com, or post them as replies to this forum topic.
PS. Feel free to edit/use code as you like, the license just says that you're allowed to do anything you like, as long as the license stays there, and my name doesn't get used for advertising (yeah right XD).

Description
AHKA stands for AutoHotkey Array (or AHKArray).
AHKArray provides a way to store multiple variables, as one. It eliminates the necessity for using global variable arrays that are generated by functions such a stringsplit.
This means arrays can now be stored in ONE varaible, and returned by a function. No more array variable clutter.
AHKArray supports an "infinite" amount of dimensions. (Well, as much as your memory can take without blowing up.)
Starting with v5.35, contents of Array are HEXed, enabling the use of ANY of the first 256 ASCII characters inside of them.
This library is rather heavy and feature filled. If you want a smaller, faster single variable array library, please refer to infogulch's SimpleArray. You can also take a look at a singly linked list concept showcase here.

Specifics
~ Syntax : For Non-HEXed AHKArray is similar to ActionScript
Code:
Array := "[a,b,[A,B],c]"

~ Syntax : For HEXed AHKArray is similar to a HEXed ActionScript
Code:
Array := "[61,62,[97,98],63]"
Array := AHKA_NewArray("[a,b,[A,B],c]")

~ Compatability : Conversion from standard Array%i% arrays, is inbuilt
~ Advanced Indexes :
    Index=0 : (DEFAULT) Add/Get/Remove/Set/Etc the LAST index in the array
    Code:
    AHKA_Add("[1,2,3]",BLAH) ;returns "[1,2,3,BLAH]" ;same as AHKA_Add("[1,2,3]",BLAH,0)

    Index>0 : Add/Get/Remove/Set/Etc the INDEX index in the array
    Code:
    AHKA_Add("[1,2,3]",BLAH,2) ;returns "[1,BLAH,2,3]"

    Index<0 : Skip INDEX indexes from back and then Add/Get/Remove/Set/Etc the next index
    Code:
    AHKA_Add("[1,2,3]",BLAH,-1) ;returns "[1,2,BLAH,3]"
~ Usage : Simply put the "AHKA.ahk" file into your "AutoHotkey/Lib/" directory, OR include it at the end of your program via "#Include AHKA.ahk".
~ HEX : The data stored can now be HEXed automatically
~ Chaining : All functions are chainable :
Code:
Array := AHKA_Remove(AHKA_Set(AHKA_Add(AHKA_Add(AHKA_Add(AHKA_NewArray(),"A"),"B"),"C"),"B+",2),1)
; [] -> [A] -> [A,B] -> [A,B,C] -> [A,B+,C] -> [B+,C]
~ Free-Style Decalaration (Automatic HEXing) :
Code:
myArray := AHKA_NewArray("[1,2,[31,32],4]")

Don't see a feature you want? Post it here, and I'll try to add it.

Reserved Strings for Non-HEXing
Inside AHKArray, you may not store strings containing the following symbols ONLY IF you are NOT using HEXing:
Code:
[
]
|
,

Note: Contents are automatically HEXed. This can be changed by calling AHKA_SetDebug(true) to disable HEXing, and AHKA_SetDebug(false) to enable HEXing.

Version History
Quote:
Version 0
First release
Basic functions work
Dimensions work up to 2D (in most cases)
Version 1 - 3
Fixed a bug with adding to an empty array.
Added Insert function
Added a "Documentation"
Added a Convert function (now, all the functions that generate Array%i% kind of arrays, can also be used with AHKAArray (the generated variable Array%i% must be global!)
Changed array format
It is now possible to say this:
Code:
Array = "{1,2,3,4}"
To declare an array
Fixed an error with Get()
Version 4
Completely rewrote scripts (thus fixing lots of bugs)
All basic functions work (as tested) for as many dimensions as needed
Array Syntax changed to Flash-Style
Code:
Array = "[1,2,[31,32,[331,332],34],4,5]"

Added Split() function
Version 5
Initial:
Completely rewrote scripts from scratch ... again
All functions work (as tested) for as many dimensions as needed
Sample code included
Array dimensionality is now supported by Parse/Unparse functions (wrongly named so =P)
Patched:
Added Sort() function
Added Swap() function
Added Minimum() function
Added Maximum() function
Added Find() function
Added Reverse() function
Added Merge() function
Added Trim() function
Added Mathematical Floor(),Abs() functions
Upgraded Get() function
Added String() function
Added HEX support
Get() and Set() functions Overloaded
Set() function speed improved
Fixed Remove() function for arrays
Version 6
Overloaded every major function.
Added freestyle array declaration to NewArray.
Changed to Library format, #include not necessary anymore.
Optimized various functions.
Added "debug mode" (dynamic non-HEXing mode).
Made a new Documentation.
Created (still creating) complete AHKA tester (with GUI), usable as sample code.


Documentation
Documentation & Tutorials for AHKA are availiable here.
Note: Utility functions are not yet documented, but are also not meant to be used on their own (only by other functions), so no functionality is lost.
Note: Tutorials are still under construction, sorry.


Last edited by olegbl on November 7th, 2008, 9:58 pm, edited 54 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2006, 8:17 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
Since there are still several commands and functions that will only output to a regular array, how about a function that converts a regular array to an AHKArray? It would be a lot easier to use then, instead of having to do something like this:

Code:
NewArray := AHKANewArray()
Loop %Array0%
   AHKAAdd(NewArray,Array%A_Index%)


Edit: Did you add that while I wasn't looking? :lol:

Any plans for hash tables, stacks, queues, trees? :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2006, 9:40 pm 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
Yup, added it behind your back :P
I'm currently upgrading the whole script, and slightly changing the format, to make it a lot easier to use, etc...
Will post V3 soon.

Edit: Done

Edit2: Oh, didn't see the question, looked like signature XD
Well, for now, this is pretty much as far as I'm going, though, later on I will probably add everything from full character storing compatibility, to auto-sorting, and byte-storage
(the whole reason I did this, is because I'm making a code-wise self updater (i already made like 3, but they suck), and I need local variable arrays for it, (to make it much more efficient, and not global)

Edit3: Er, I've decided against taking this to an actual array level, that can be done in AHKv2 or whatever it is thats being talked about, but for now, I think this is plenty good enough to have...
If anyone wants to do it though, haha, go ahead =P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2007, 5:55 am 
Offline

Joined: September 12th, 2005, 2:12 am
Posts: 190
I have some unfinished functions I wrote for another AHK project that might be useful to you. It has "remove from queue" and "remove from stack" support for standard AHK (fake) arrays. There are also some other array functions like PrintArray and CollapseArray.

http://www.autohotkey.com/forum/viewtop ... her+method


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2007, 3:42 am 
is any1 reading this if so i have this problem this code produces a msgbox with zero on it what am i doing wrong
Code:
charArray := AHKANewArray()
Loop,5
   AHKAAdd(charArray,65)
var := AHKASize(charArray)
MsgBox %var%

Thanks


Report this post
Top
  
Reply with quote  
 Post subject: invalid array format
PostPosted: March 4th, 2007, 7:06 pm 
Offline

Joined: October 8th, 2006, 8:18 pm
Posts: 96
Location: denmark
hi,

It seems no matter what I do I get back an invalid array format error, here are the various ways I have tried to declare an array:

xarray = [1, 2, 3]

xarray = "[1,2,3]"

xarray := "[1,2,3]"

xarray := "{1,2,3}"

xarray = "{1,2,3}"

xarray := AHKANewArray()

xarray := AHKAAdd(xarray,1)

after which I try to do the following



xindex = 1



xindex := 1

either one I don't care

finally


#r::
xvalue := AHKAGet(xarray,1)

return

which tells me that I have an invalid array format.

thank you


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2007, 12:31 am 
Yeah im having the same problem i posted my code before and it seems im doing it right but the array never initializes and i always get array format errors


Report this post
Top
  
Reply with quote  
PostPosted: March 6th, 2007, 10:28 am 
Offline

Joined: October 8th, 2006, 8:18 pm
Posts: 96
Location: denmark
I'm going to suppose that the culprit is the version of Autohotkey used. I'm using 1.0.46.09, anyway I figure that, given the multitudinous variations I've done that it is not going to work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2007, 5:24 am 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
Err, sorry for a rather long non-reply.
Was busy, didn't do AHK.
Right now, I'm writing a much better, more efficient version of AHKArray (from scratch).
As for the questions, I'll try to answer (though late):
Re-Guest:
when you use functions, you gotta set your array to equal them...
Code:
charArray := AHKANewArray()
Loop,5
   AHKAAdd(charArray,65)
var := AHKASize(charArray)
MsgBox %var%
doesn't work, but
Code:
charArray := AHKANewArray()
Loop,5
  charArray := AHKAAdd(charArray,65)
var := AHKASize(charArray)
MsgBox %var%
should work.

Re-Pantagruel:
Code:
xarray := "[1,2,3]"

should work.
Code:
xvalue := AHKAGet(xarray,1)
MsgBox, %xvalue%

should work too.

However, if they don't, maybe it is because of AHK version like was mentioned...
Well, I'm working on AHKArray v5 (im using the newest AHK version to do so)... So, I'll get it done in a few days.
(Hopefully including some code examples =P)

PS Don't forget the #include AHKArray.ahk at the end of your prog.

==EDIT==
Worked until midnight, but here's V5... hopefully should work for pretty much everything... didn't do TOO much testing yet..


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 4:47 pm 
great! and perfect!!

also really impressive documentation!!!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2007, 11:13 pm 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
Thanks!

Next version will be out sometime soon.
(I think there's 3 new methods, maybe more)
(Not this weekend though, too busy...)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2007, 2:25 am 
Offline

Joined: October 28th, 2006, 2:14 am
Posts: 297
Location: US
So you can't use certain characters? how about converting to hex so that all letters can be used, and you can use many more delimiters. Of course the size of it will be multiplied by 2...

_________________
Changed siggy at request of ahklerner :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2007, 4:05 am 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
Well, I was thinking of instead putting 4 optional parameters at the end of each function specifying delimeters, so they could be customized.
However, I do like the HEX idea, thanks!
Might implement that in the next version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2007, 12:43 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Maybe have a initialize function to change the characters. Then it only needs to be set once.

How do I get values from a mutiple dim array? I have to call AHKAGet multiple times, right? Could there be a function that gets the value by, e.g.
AHKAValue(MyArray, IndexDim1, IndexDim2, IndexDim3, etc. up to IndexDim10)?
By making the indicies optional and limited to 10 dims it should be possible.

Is there an option to sort numerically?

Just my two cents.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2007, 5:00 pm 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
Well, to make an init function, the variables would have to be global, which is what I've been trying to avoid...
I did however already implement HEX... This removes the ability to say
Code:
Array :="[a,b,c]"
;Instead, you must now say
Array := "[61,62,63]"

And it also limits the storage capacity to the first 255 ascii chars, but it does remove the limitation for dilimeter characters.
I added an easy way to enable/disable HEXing, which requires a simple change of "false" to "true" in two places.

To get a value from multiple dimension you could say:
Val := AHKAGet(AHKAGet(AHKAGet(Array,X),Y),Z)
But, it would be rather easy to implement the multiple index thing, so I'll try to do it.

Numerical sorting, I think is the same in AHK, so the sort method should do that. (it basically compares values to each other using the > and < symbols which work both ways as far as I know)

Thanks for you suggestions!

I'll try to get all this stuff implemented and released in the next version...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 97 posts ]  Go to page 1, 2, 3, 4, 5 ... 7  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: azure, lblb and 19 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