mIRC Home    About    Download    Register    News    Help

Print Thread
Arrays #167817 31/12/06 04:12 AM
Joined: Dec 2006
Posts: 1
E
ecliptik Offline OP
Mostly harmless
OP Offline
Mostly harmless
E
Joined: Dec 2006
Posts: 1
i knwo you got tokens but i'd like to see arrays too

for eample

Array[0] = test,test2,test3
Array[1] = test4,test5

then i can use the tokens to get them split

example of making a array

/array Array1
/aset Array[0] blah
Array(Array1).length
Array(Array1,blah).append
/aunset Array1

Re: Arrays [Re: ecliptik] #167820 31/12/06 04:56 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I can't see a use for arrays unless they support multi-dimension. If not, then hash tables can do the same things, essentially.

/hmake array
/hadd array [1] blah
$hget(array,0).item
(not sure what the .append would do)
/hfree array

If arrays were added, a FOREACH structure should be added with it, as it would permit simpler loops with arrays.

-genius_at_work

Re: Arrays [Re: genius_at_work] #167825 31/12/06 07:40 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I think hash tables are fine enough for this, I know you know but hash tables can appear to do multi dimensions anyway with ex, /hadd array [1/1/5] for instance, but of course were just really making up unique item names, but it comes to the same result.

ps: I think his .append would add an item to the end of the array

Re: Arrays [Re: DaveC] #167828 31/12/06 09:26 AM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
An array feauture would be a really nice option if it will allow you to pass complete arrays to aliases.
It would also be a cleaner option then a temporary hash table.

Since arrays are "Sorted" i wouldn't class them the same as an hash table eventhough you can "fake" array support in mIRC by using hash tables.

A foreach structure to go with it would indeed be total sweetness.

Oh well just wait and see if suggestion #342342 makes it smile






$maybe
Re: Arrays [Re: ecliptik] #167832 31/12/06 12:58 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
Signed. Hashtables are a shoddy workaround at best. They may work, but they're missing many advantages that true array support would bring.

Re: Arrays [Re: Mpdreamz] #167865 31/12/06 10:21 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I asked a little birdy i know, and it said, they are stuck working on suggestion #19, but they welll get to #342342 when its turn comes up. :-)

Re: Arrays [Re: DaveC] #167877 01/01/07 12:56 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Speaking of .append, I'd love to see something like that for hash tables. I'd rather than have to do something like:

/hadd table item $hget(Table,item) appended_data

I'd rather do something like:

/hadd -a table item appended_data


Invision Support
#Invision on irc.irchighway.net
Re: Arrays [Re: Riamus2] #168384 08/01/07 03:05 AM
Joined: Oct 2006
Posts: 48
G
Ghozer Offline
Ameglian cow
Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
If you use arrays, use a similar method to php arrays, this will allow multi dimensional, arrays within arrays, and named array items...

in php its $var = array("item_name1" => "item1", "item_name2" => "item2)

then its just $var['item_name1'] to retrieve the info..

the mIRC equivelent would be something like

var %moo = $array(item_name1 = item1, item_name2 = item2)

then just %moo[item_name1] or something, maybe have an appendage on the variable to say your calling an array item, maybe something like... &%moo item_name1

Last edited by Ghozer; 08/01/07 03:06 AM.
Re: Arrays [Re: ecliptik] #168400 08/01/07 05:46 AM
Joined: Apr 2004
Posts: 218
P
PhantasyX Offline
Fjord artisan
Offline
Fjord artisan
P
Joined: Apr 2004
Posts: 218
Longer Variables would be nice too. *shrugs*


Live to Dream & Dream for Life
Re: Arrays [Re: Mpdreamz] #170718 13/02/07 06:19 AM
Joined: Oct 2006
Posts: 6
L
Ledah Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
L
Joined: Oct 2006
Posts: 6
We sure can do a workaround for Arrays, but im for the idea that true arrays would be better. a For Loop WOULD be simpler than the current Whiles we have too.
On the same way, the WhileFix is a nice workaround BUT having it as a true mirc function would surely increase its potential

So... we should be around #32 by now... and arrays is #342342 ? Let's change that a little ;p
$left(#342432,3) ftw!

Last edited by Ledah; 13/02/07 06:21 AM.
Re: Arrays [Re: ecliptik] #170724 13/02/07 12:32 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
Just something similar to the hashtable implementation would be enough:

Code:
acopy <array1> <array2>
; Copy an array to another.

amake <array> <size>
; Create an array.

aadd [-imo] <array> [N] <data>
/*
Add data to an array.
-i = insert <data> at position [N]
-m = make array if it doesn't already exist.
-o = overwrite item at position [N] with <data>
*/

adel <array> <N>
; Delete an item from an array.

aunset <array>
; Delete an array.

$aget(<array>,<N>)
; Get data from an array.

$afind(<array>,<wildcard/regex>,[rw],<N>)
/*
Find data within an array.
r = regex comparison
w = wildcard comparison
*/


The main advantage over hashtables would be that they could be used to store sorted data, without having to use slow file access. As per usual, using 0 for the <N> parameters for the identifiers will return the number of found matches / total number of items.

Re: Arrays [Re: hixxy] #170735 13/02/07 07:14 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
You can sort hash tables very quickly and easily using /filter. Even tables with thousands of items can be sorted very quickly.


Invision Support
#Invision on irc.irchighway.net
Re: Arrays [Re: Riamus2] #170737 13/02/07 07:16 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
/filter does not support hashtables.

Even if it did, it wouldn't work, because they are unsorted. Hashtables are stored as a key/data pair, so their order does not matter, as to retrieve data you must know the key.

Re: Arrays [Re: hixxy] #170742 13/02/07 09:55 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Filter does actually work. DaveC gave a very good example a year or two ago about doing it. It's a matter of a save of the table (data only), filtering that includes line numbers, and the calling the data by the line number. That's probably not a very accurate description, but I don't have the code in front of me.

Yes, it's a workaround, but it allows very quick sorting of the hash tables with very little coding necessary to do it (under 5 lines).


Invision Support
#Invision on irc.irchighway.net
Re: Arrays [Re: Riamus2] #170743 13/02/07 09:57 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
If you save the table then it's acting on a file, not a hashtable. /filter does not support hashtables.

That is also not sorting the data. Well, it is, but the data inside of the table is still unsorted, but you can use a number as an item/key to sort the data yourself - this is not a built-in hashtable sort routine, but a workaround. It doesn't change the fact that hashtables are unsorted.