| | 
| 
| 
|  |  
| 
ecliptik
 |  
| ecliptik | 
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
 |  |  |  
| 
| 
|  |  
| 
Joined:  Oct 2005 Posts: 1,671 Hoopy frood |  
|   Hoopy frood Joined:  Oct 2005 Posts: 1,671 | 
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
 |  |  |  
| 
| 
|  |  
| 
DaveC
 |  
| DaveC | 
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
 
 |  |  |  
| 
| 
|  |  
| 
Joined:  Apr 2004 Posts: 755 Hoopy frood |  
|   Hoopy frood Joined:  Apr 2004 Posts: 755 | 
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   |  |  |  
| 
| 
|  |  
| 
Joined:  Sep 2005 Posts: 2,630 Hoopy frood |  
|   Hoopy frood Joined:  Sep 2005 Posts: 2,630 | 
Signed. Hashtables are a shoddy workaround at best. They may work, but they're missing many advantages that true array support would bring. |  |  |  
| 
| 
|  |  
| 
DaveC
 |  
| DaveC | 
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. :-)
 |  |  |  
| 
| 
|  |  
| 
Joined:  Oct 2004 Posts: 8,061 Hoopy frood |  
|   Hoopy frood Joined:  Oct 2004 Posts: 8,061 | 
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
 |  |  |  
| 
| 
|  |  
| 
Ghozer
 |  
| Ghozer | 
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.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Apr 2004 Posts: 217 Fjord artisan |  
|   Fjord artisan Joined:  Apr 2004 Posts: 217 | 
Longer Variables would be nice too. *shrugs* |  |  |  
| 
| 
|  |  
| 
Ledah
 |  
| Ledah | 
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.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Sep 2005 Posts: 2,630 Hoopy frood |  
|   Hoopy frood Joined:  Sep 2005 Posts: 2,630 | 
Just something similar to the hashtable implementation would be enough: 
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. |  |  |  
| 
| 
|  |  
| 
Joined:  Oct 2004 Posts: 8,061 Hoopy frood |  
|   Hoopy frood Joined:  Oct 2004 Posts: 8,061 | 
You can sort hash tables very quickly and easily using /filter.  Even tables with thousands of items can be sorted very quickly. |  |  |  
| 
| 
|  |  
| 
Joined:  Sep 2005 Posts: 2,630 Hoopy frood |  
|   Hoopy frood Joined:  Sep 2005 Posts: 2,630 | 
/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.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Oct 2004 Posts: 8,061 Hoopy frood |  
|   Hoopy frood Joined:  Oct 2004 Posts: 8,061 | 
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).
 |  |  |  
| 
| 
|  |  
| 
Joined:  Sep 2005 Posts: 2,630 Hoopy frood |  
|   Hoopy frood Joined:  Sep 2005 Posts: 2,630 | 
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.
 |  |  |  | 
 |