 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
infogulch
Joined: 27 Mar 2008 Posts: 353
|
Posted: Tue Oct 28, 2008 11:43 am Post subject: |
|
|
lol, TT() is a debug function I was using, I'll get rid of it.
I changed the delimiter and encoding character to the BS (asc 8 ) and BEL (asc 7) chars, respectively. I used the clipboard to copy it into, so it shouldn't be a problem. I may upload it to ahk.net later if you still have trouble, but it shouldn't be any big deal. _________________
A great Beginner's Tutorial |
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 353
|
Posted: Tue Oct 28, 2008 4:34 pm Post subject: |
|
|
okay, I updated it. New (still incomplete) docs on the first post. You can now download it directly. Also fixed some bugs, mistypes, etc. _________________
A great Beginner's Tutorial |
|
| Back to top |
|
 |
freakkk
Joined: 29 Jul 2005 Posts: 179
|
Posted: Wed Oct 29, 2008 5:08 pm Post subject: |
|
|
You did a really nice job with this
The extra time & thought you put into its design are greatly appreciated! _________________ .o0[ corey ]0o. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 766
|
Posted: Sat Jan 17, 2009 11:46 am Post subject: |
|
|
I am still VERY interested in continued development of this. While I have been constantly coding with the new named-index test version of the script, I haven't had much time to actually test is, because most of it has been in SteamWin and SteamLab which are currently both broken.
I'm just curious if you have plans to continue or expand these functions at all, or if you're satisfied with where they are at now?
Thanks a lot for implementing my request and making these great functions! _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 353
|
Posted: Sat Jan 17, 2009 2:46 pm Post subject: |
|
|
Thanks for your support guys.
There are two things I'm considering changing.
The first, and most obvious, thing I want to change is adding nested support to all the functions, not just SA_Get(). I think I will need to add functions, not just change them, because of the param situation.
I'm also considering changing the syntax a little. I don't know if I will add another set of functions for the new syntax, or just change the whole library. The idea is: using the functions without forcing you to assign the array to itself, but instead using ByRef params. This would give shorter syntax. But I'm still deliberating about doing it at all.
After making the functions nested, I probably won't add much. Honestly, as I continue coding in ahk, as well as other languages, I believe more and more that arrays should really be handled by the parent language, and not made in native code. I am proud of my library, but it simply won't work for high performance needs, or binary. Both of which could be much more easily achieved in the parent language.
 _________________
A great Beginner's Tutorial |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 766
|
Posted: Sat Jan 17, 2009 7:01 pm Post subject: |
|
|
I agree; AHK should support single-var and multi-dimensional arrays natively. So far, SimpleArray has been the best solution I've been able to find to simulate that functionality, however, due to its simplicity.
AHK isn't the greatest at handling binary data anyway, so SA is not far behind in that aspect . A workaround is almost always required if there is any chance of a NULL character being in the data, since most AHK commands and functions expect null-terminated variables and will not work past the first one found.
I hope the fact that there are so many (good) user-developed array libraries indicates to Chris how big of a need there is for standard, internal multi-dimensional array handling functions in AHK. Until then, I'm very glad this one exists and thank you immensely for it  _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
Snaky Cake Guest
|
Posted: Tue Feb 03, 2009 5:34 pm Post subject: |
|
|
Could somebody post basic demonstrations for these functions as I'm having trouble with just SA_Get() and really don't have clue if I'm using SA_Del() correctly either
SA_Set(Queue,8,1)
var1 := SA_Get(Queue,1)
SA_Set(Queue,3,2)
SA_Del( Queue, 1)
var2 := SA_Get(Queue,1)
I would assume that var1 := 8 and var2 := 3 but I get blank outputs with MsgBox
Sorry for the missing code tag, code button does nothing |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 766
|
Posted: Tue Feb 03, 2009 5:49 pm Post subject: |
|
|
Your var1 seems like it should work correctly, putting the value 8 at index 1.
After you delete index 1, it will no longer exist, so your var2 should be blank.
To get the 2nd index you would use SA_Get(Queue, 2) _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
Snaky Cake Guest
|
Posted: Tue Feb 03, 2009 6:11 pm Post subject: |
|
|
I understand that var2 would come out blank (I was hoping for dynamic index handling) but the problem is that the var1 comes out blank.
var3 := SA_Set(Queue,8,1)
This on the other hand does give out the correct value.
Could this have something to do with the fact that I'm using the latest beta of AHK? |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 766
|
Posted: Tue Feb 03, 2009 7:12 pm Post subject: |
|
|
Wait, I just noticed that you weren't using Set properly.
Set requires the array to be defined in the first parameter, like you did, but it doesn't modify that array. Rather, it outputs a new array as a return value.
Try this:
| Code: | Queue := SA_Set(Queue, 8, 1)
var1 := SA_Get(Queue, 1)
Queue := SA_Set(Queue, 3, 2)
SA_Del(Queue, 1)
var2 := SA_Get(Queue, 1)
var3 := SA_Get(Queue, 2) |
_________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 353
|
Posted: Tue Feb 03, 2009 10:53 pm Post subject: |
|
|
Oh! I didn't even realize my thread was being posted on, I wasn't getting emails. Sorry about that.
Yes, Snaky Cake, the issue is that you have to assign the array to the return value of set.
That's what I was talking about changing up above. Maybe it's a good idea after all. _________________
A great Beginner's Tutorial |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 766
|
Posted: Wed Feb 04, 2009 1:06 am Post subject: |
|
|
I'm torn, really.
I think ultimately it's a good idea to return the array under the ByRef of the first parameter, to avoid having to do too much moving of the array in memory (especially for large arrays).
It's sometimes nice to have the array returned, however, such as when you're directly using that return value instead of just storing it in a variable, such as using it in another function.
Perhaps there should be a Set function which sets inline (using the ByRef) and a SetRet function which Sets and returns the array as is the current behavior?
Or maybe it should be the other way around; maybe Set should stay the same and instead SetRef or something should be created that sets the array directly in the first parameter (for speed).
Hmmm... _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
Snaky Cake Guest
|
Posted: Wed Feb 04, 2009 6:54 am Post subject: |
|
|
I understood the mechanism for set & get now. But I had problems with del .
I can't delete arrays last item. Is this a "right way"
Queue := 0
to seemingly destroy the array?
Well I got my code working so thanks a lot. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 766
|
Posted: Wed Feb 04, 2009 10:19 am Post subject: |
|
|
I'm actually having some trouble now.
Trying to use named indexes to create an array of files and dependencies.
Basically the array should look like this:
Dependency1.esp => {
1 => {
1 => ParentFile1.esp,
2 => Description of dependency...
},
2 => {
1 => ParentFile2.esp
2 => Description of dependency...
}
},
Dependency2.esp => {
1 => {
1 => ParentFile1.esp,
2 => Description of dependency...
},
2 => {
1 => ParentFile2.esp
2 => Description of dependency...
}
},
etc...
I'm doing it like this:
| Code: | ; Create the parent array (name and description)
File := SA_Set(File, "ParentFile1.esp")
File := SA_Set(File, "Description of dependency...")
; Get the current parents if any exist
Dep1Files := SA_Get(Dependencies, "Dependency1.esp")
; Add to the current parents of this dependency
Dep1Files := SA_Set(Dep1Files, File)
; Set the dependency back into the main array
Dependencies := SA_Set(Dependencies, Dep1Files, "Dependency1.esp")
; Create a second parent array
File := ""
File := SA_Set(File, "ParentFile2.esp")
File := SA_Set(File, "Description of dependency...")
; Get the current parents if any exist
Dep2Files := SA_Get(Dependencies, "Dependency2.esp")
; Add to the current parents
Dep2Files := SA_Set(Dep2Files, File)
; Set the dependency back into the main array
Dependencies := SA_Set(Dependencies, Dep2Files, "Dependency2.esp")
MsgBox,% SA_Len(Dependencies)
|
The array only has one index instead of two.
I'm still trying to figure out exactly what is going wrong, but it seems to put everything underneath the first named index, never even creating the second. I can't seem to get past this using named indexes. I believe it works OK using standard numbered indexes however. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 353
|
Posted: Thu Feb 05, 2009 2:32 am Post subject: |
|
|
Snaky Cake: yes, that would clear the array, but I would suggest you set it to blank instead of 0. e.g.
bmcclurre: interesting issue, I'm looking into it. _________________
A great Beginner's Tutorial |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|