AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The AHKer's Prayer
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Icarus



Joined: 24 Nov 2005
Posts: 440

PostPosted: Sun Jun 22, 2008 2:59 pm    Post subject: The AHKer's Prayer Reply with quote

Dear lord of the autohotkey realm.
Can we have normal arrays soon? Records maybe? Some other way to store, pass and return more complex data types (byval or byref) ?

I promise to be a good boy forever...

Smile
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
argneo



Joined: 14 Sep 2007
Posts: 124

PostPosted: Tue Jun 24, 2008 2:27 pm    Post subject: Reply with quote

me too Laughing
_________________

WoW
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 679

PostPosted: Tue Jun 24, 2008 4:39 pm    Post subject: Reply with quote

byref is already part of ahk look at functions
and i second the motion for true arrays
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Raccoon



Joined: 02 Jan 2008
Posts: 70
Location: Freenode IRC

PostPosted: Sat Jul 05, 2008 5:13 pm    Post subject: Reply with quote

What makes a "true array"? the fact that the contents of the array presumably exists in the same memory address block? What's the big deal between the two examples below?

Array[i] = test
Array%i% = test

zomg! I can't stand how wide percent signs are... they must be square-braces or I'm not playing with you anymore!
_________________
Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #autohotkey
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 679

PostPosted: Sat Jul 05, 2008 5:38 pm    Post subject: Reply with quote

i think what the user is lookin for here is some of the other things that come with arrays
multi dimensional arrays and the ability to get a count of items in the array as well as the ability to stor other than strings and numbers oh i dunno objects but then ahk is not an OOP language
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Raccoon



Joined: 02 Jan 2008
Posts: 70
Location: Freenode IRC

PostPosted: Sat Jul 05, 2008 5:58 pm    Post subject: Reply with quote

Multi dimensional array...

Array%x%%y%%z% = test
same as Array[x][y][z] in other languages.

You can keep your own count. Most languages don't keep count for you, and those that do are slow.

AHK only has string/numeric values, as you already pointed out.
_________________
Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #autohotkey
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 679

PostPosted: Sat Jul 05, 2008 6:09 pm    Post subject: Reply with quote

I DIDNT KNOW ABOUT THE ABULITY TO DO MULTI DIMENTIONAL ARRAY
THANKS
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Icarus



Joined: 24 Nov 2005
Posts: 440

PostPosted: Sat Jul 05, 2008 6:12 pm    Post subject: Reply with quote

It is not a question of true arrays, and not a question of multi dimensional arrays.

AHK does not have ANY arrays, not to mention "true arrays"
AHK has variables, and it allows you to use other variables as a part of the variable name. Thats it.

Array is a self contains unit of information that can be referred to by using one name. It can be passed from one function to another for further manipulations.

The Item%A_Index% variables are very comfortable in AHK - it makes it very easy to do a lot of things, but it cannot be a replacement to arrays.
If you are doing a short script (lets say under 1000 lines), this is sufficient and there are workarounds for any problem.

But when you start having longer scripts, with many functions, and many data types, it gets out of control rapidly.

If you want to pass full arrays from one function to another, you have two choices in AHK (maybe more, but these are the obvious):

Make the "array" global, and by this you may have to make your function's completely Global, unless you want to declare every item in your array.

or

Compress the array into one string ("1,2,3"), then decompress it inside the function (StringSplit), then do your thing on the array items, and compress it again into one string in order to return it.
Of course, the caller will also have to decompress the full string again, and put it into array items.

Thats labor intensive, thats messy, thats not how it should be done.
_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Raccoon



Joined: 02 Jan 2008
Posts: 70
Location: Freenode IRC

PostPosted: Sat Jul 05, 2008 6:43 pm    Post subject: Reply with quote

You can pass an array to a function just as easily as creating the array using dereferencing. You will need to practice with this.

Code:
start:
  n := 1
  myarray%n% = hello world ; or simply myarray1 = hello world
  myfunction("myarray")    ; notice the quotes, you're passing the name (aka, pointer) of the array.
  msgbox % myarray%n%      ; what strikes me is that this works without Global prefix in the function.
  msgbox % myarray1        ; again, just play with it until you get the nack.
return

myfunction(thisarray)
{
  msgbox %thisarray%1    ; prints "myarray1"
  msgbox % %thisarray%1  ; prints "hello world"
  %thisarray%1 = goodbye
}


_________________
Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #autohotkey
Back to top
View user's profile Send private message
Icarus



Joined: 24 Nov 2005
Posts: 440

PostPosted: Sat Jul 05, 2008 7:02 pm    Post subject: Reply with quote

Thank you for trying to help, but I am not looking for answers.
I know all this, and this is not a solution.

Your code works only because all your items in Start: are global.
What you did was in fact my first solution from the previous post - global.
This will not work here:
Code:

Start()

Return

Start() {
  ;Global                 ; Only if this is uncommented, this will work
  n := 1
  myarray%n% = hello world
  myfunction("myarray")    ;
  msgbox % myarray%n%      ; This worked because all variables are global in a subroutine (Label)
                           ; This will not work now, since we are in a function (i.e. all Local)
  msgbox % myarray1        ; this will not be goodbye
}

myfunction(thisarray)
{
  msgbox InFunction 1: %thisarray%1         ; prints "myarray1"
  msgbox % "InFunction 2: " . %thisarray%1  ; does not print "hello world"
  %thisarray%1 = goodbye                    ; does not effect the array
}



What AHK has is similar to a partial implementation of associative arrays (hash) - only there is one thing missing to make it be considered as a more complete implementation, and this is the ability to treat it as one unit, as I mentioned earlier.

Array%FirstName% := "Name"
Array%LastName% := "Last Name"
So far so good, but this should also AUTOMATICALLY create the following two variables:

Array - which should contain the above two - this way we will be able to pass it to functions as one unit
Array.Count or Array0 or anything else that will include the item count and will be updated AUTOMATICALLY whenever a new item is added.

Anyways, thanks for trying to assist, but I was just praying Smile
_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
tank



Joined: 21 Dec 2007
Posts: 679

PostPosted: Sat Jul 05, 2008 10:29 pm    Post subject: Reply with quote

deleted by user not sured how it got double posted
_________________
Read this
Com
Automate IE7 with Tabs


Last edited by tank on Mon Jul 07, 2008 6:51 am; edited 1 time in total
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Sun Jul 06, 2008 12:30 pm    Post subject: Reply with quote

Ofc Icarus, we all want that.

Language without basic concepts as arrays can never be good. "Conceptual arrays" as we have them now are just poor mans solution.
_________________
Back to top
View user's profile Send private message MSN Messenger
Icarus



Joined: 24 Nov 2005
Posts: 440

PostPosted: Sun Jul 06, 2008 12:33 pm    Post subject: Reply with quote

Thanks majkinetor,

I was waiting for some backup here... Smile
_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
tank



Joined: 21 Dec 2007
Posts: 679

PostPosted: Mon Jul 07, 2008 6:51 am    Post subject: Reply with quote

i was trying too but i dont have maj clout in this community
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Icarus



Joined: 24 Nov 2005
Posts: 440

PostPosted: Mon Jul 07, 2008 7:15 am    Post subject: Reply with quote

Smile
thanks tank
_________________
Sector-Seven (Music and Utilities)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group