AutoHotkey Community

It is currently May 26th, 2012, 7:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 97 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author Message
 Post subject:
PostPosted: May 24th, 2008, 9:34 pm 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
I didn't look in depth at the code, however, if it takes a long time, that's normal. My library was built (so far) for functionality rather than speed. It IS very slow in some parts. It comes from it having to parse and unparse the same humongous string numerous times. If you look at your 100-element array, it's just one super-long, formatted string, meaning it takes a while to work with. That's a minus towards this system, but, well, there really isn't any other way to make single-variable arrays, at least until we get OOP, or in the very least pointer support.

PS. Sorry everyone that V6 is taking so long, I haven't had much time lately to work...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 1:44 pm 
Hi,
sorry for this stupid question.. ;)

how can i import your scrpt in my own..
i tried #include
but i stil get this error:

Call to nonexistent function.

Specifically: AHKA_NewArray()

---> 012: myArray := AHKA_NewArray()


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 3:46 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
@newb:
Wild guess, place your include at the BOTTOM of your script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 5:30 pm 
i tried ;)

here is my complet test source-code:

myArray := AHKA_NewArray()
myArray := AHKA_Add(myArray, "Hello")
myArray := AHKA_Add(myArray, "World")

My2nd := AHKAGet(myArray,2)

msgbox %My2nd%
#include C:\Programme\Tools\AutoHotkey\Extras\Scripts\AHKArray.ahk


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 7:07 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
@newb
1) use the code tags
Code:
[code][/code]

2) use the proper function
Code:
myArray := AHKANewArray()
myArray := AHKAAdd(myArray, "Hello")
myArray := AHKAAdd(myArray, "World")

My1 := AHKAGet(myArray,1)
My2 := AHKAGet(myArray,2)

msgbox % My1 " " My2
[/code]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2008, 11:35 pm 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
Like HugoV said, the "AHKA_NewArray()" syntax is only for version 6 (which is still in alpha/beta, sorry guys, it'll be done soon...). Version 5, which is apparently what you're using ("AHKArray.ahk" rather than "AHKA.ahk"), uses "AHKANewArray()", so for now, refer to the documentation inside the post rather than the js (extjs) one I'm making for Version 6. Hope that fixes your problems.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 4th, 2008, 1:28 pm 
@ HugoV

thanks, it works ;)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2008, 8:48 pm 
Code:
#Include AHKArray.ahk
stacks:= AHKANewArray()  ; []
stacks:= AHKAAdd(stacks,2800) ; [2800]
stacks:= AHKAAdd(stacks,4700) ; [2800,4700]
stacks:= AHKAAdd(stacks,0)      ; [2800,4700,0]

stacks:= AHKASort(stacks,2) ;[4700,2800,0]
Var:=    AHKAGet(stacks,2) ; var=0
MsgBox %var%
ExitApp

the new sorted arrey looks like [4700,0,2800] instead of my expectation [4700,2800,0]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2008, 9:10 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Try with 1 & -1
Code:
stacks:= AHKASort(stacks,1) ;[4700,2800,0]
stacks:= AHKASort(stacks,-1)  ;[0,2800,4700]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2008, 9:25 pm 
Code:
stacks:= AHKASort(stacks,1) ;returns this [2800,0,4700]


from the first page of this thread:
Code:
Var := AHKASort(Array,Type=1,Start=0,End=-1)
;If Type=0 Sorts and returns the array to Var, using different values for Start & End, this shouldn't be used
;If Type=1 Sorts the array from smallest to largest. Returns the sorted array to Var.
;If Type=2 Sorts the array from largest to smallest. Returns the sorted array to Var.
;If Type!={0,1,2} Returns the original array to Var.
;If Start=0 or Start=1, array is sorted from start
;If Start>0, array is sorted starting from position Start, indexes before Start are untouched
;If End=-1, array is sorted until the end
;If End>0, array is sorted until index End, indexes after End are untouched
;Current Implementation : QuickSort


but it doesnt work like this at all


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2008, 10:02 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Never actually used the sort :oops: but it does return the correct order I think:
Code:
#Include AHKArray.ahk
stacks:= AHKANewArray()  ; []
stacks:= AHKAAdd(stacks,2800) ; [2800]
stacks:= AHKAAdd(stacks,4700) ; [2800,4700]
stacks:= AHKAAdd(stacks,0)    ; [2800,4700,0]

stacks:= AHKASort(stacks,1) ;  results in 4700,2800,0
Var0:=    AHKAGet(stacks,0) ;
Var1:=    AHKAGet(stacks,1) ;
Var2:=    AHKAGet(stacks,2) ;
MsgBox % var0 "," var1 "," var2  ;  4700,2800,0
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2008, 10:24 pm 
unfortuneatly it doesnt. if u fill ur array in different order then it wont work with your solution.
Code:
#Include AHKArray.ahk
stacks:= AHKANewArray()  ; []
stacks:= AHKAAdd(stacks,0) ; [0]
stacks:= AHKAAdd(stacks,2800) ; [0,2800]
stacks:= AHKAAdd(stacks,4700)    ; [0,2800,4700]

stacks:= AHKASort(stacks,1) ;  results in 4700,0,2800
Var0:=    AHKAGet(stacks,0) ;
Var1:=    AHKAGet(stacks,1) ;
Var2:=    AHKAGet(stacks,2) ;
MsgBox % var0 "," var1 "," var2  ;  4700,0,2800
ExitApp


not to mention if u use longer array. i couldnt figure out the logic behind it but it defenietly does not work properly. i hope oleg will look into it...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 7:29 pm 
Offline

Joined: March 19th, 2007, 12:43 am
Posts: 532
this is sweet!
What's with your site? It's all under construction.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 8:19 pm 
Offline

Joined: March 19th, 2007, 12:43 am
Posts: 532
I don't understand how to use it.
How do i create/read multidimensional arrays? Your documentation is practically blank.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 22nd, 2008, 5:14 pm 
Offline

Joined: December 13th, 2006, 7:16 am
Posts: 48
Sorry for the long time non-reply, I was on vacation, without a pc...
For the sort function to work, you would have to use the beta of version 6.
However, I still haven't finished the documentation for the version 6. (I have more done than is published but, no done yet)

So, here's the trick.
Use version 5 for now.
To have the sort work, simply download v6 beta and copy-paste the code the AHKA_Sort() function into the v5 replacing the AHKASort() function. Then rename it AHKASort() [as opposed to AHKA_Sort()] to make it consistent with v5 format.

Sorry it's taking so long, making a proper documentation must be the most annoyingly repetitive thing i've ever done in my life... But I'll get it done.

@neXt :
Use version 5, and documentation on this site, rather than the new one.

@HugoV :
@Dinky Island :
I'm pretty sure the quicksort in version 6 works, I've tested it quite a bit. Try to copy-paste it into version 5 as described above.


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 Previous  1, 2, 3, 4, 5, 6, 7  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: chenhaiyang and 6 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