mIRC Home    About    Download    Register    News    Help

Print Thread
hashtables #144927 16/03/06 01:43 PM
Joined: Dec 2002
Posts: 94
K
krunch Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Dec 2002
Posts: 94
I see that using hashtables there is no order
is there anyway to order this?
anythoughs


Lets get dirty
Re: hashtables #144928 16/03/06 05:14 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Order (sort) based on what?
Item names? Data values? Item creation dates? The Blue Fairys Diary? smile

Re: hashtables #144929 16/03/06 08:58 PM
Joined: Dec 2002
Posts: 94
K
krunch Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Dec 2002
Posts: 94
time added so first added is first showen


Lets get dirty
Re: hashtables #144930 16/03/06 09:29 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
There is no method of doing this with out altering the item and or data becuase hashtables dont store information insertion/update dates

I would suggest if this is an important feature to what ever yuur doing you swap to using a hidden window, some sample code below
Code:
alias -l hidden.window.name {
  var %window = @ACTUAL.WINDOW.NAME.HERE
  window -h %window
  return %window
}
alias hw_name { return $hidden.window.name }
alias hw_add {
  ;$1 = item name
  ;$2-= data
  if ($0) {
    if ($fline($hw_name,$1 *,1) || $fline($hw_name,$1,1)) { dline $hw_name $v1 }
    aline $hidden.window.name $1 $2-
  }
}
alias hw_del {
  ;$1 = item name
  if ($0) && ($fline($hw_name ,$1 *,1) || $fline($hw_name ,$1,1)) { dline $hw_name $v1 }
  }
}
alias hw_get {
  ;$1 = item name
  if ($0) && ($fline($hw_name ,$1 *,1) || $fline($hw_name ,$1,1)) { return $gettok($line($hw_name,$v1),2-,32) }
}


u can use
/hw_add itemname itemdata
/hw_del itemname
$hw_get(itemname)
$line($hw_name,0) items in table
$line($hw_name,N) item N in table using inserted/updated order this line is wrong see correction below

For more exact or wild card searches you could create extra aliases or just access the hidden window yourself using $hw_name instead of the actual windowname (this way the window well always exist)

--correction--
$gettok($line($hw_name,N),1,32) itemname N in table using inserted/updated order
$gettok($line($hw_name,N),2-,32) itemdata N in table using inserted/updated order

Last edited by DaveC; 16/03/06 09:31 PM.