mIRC Homepage
Posted By: krunch hashtables - 16/03/06 01:43 PM
I see that using hashtables there is no order
is there anyway to order this?
anythoughs
Posted By: DaveC Re: hashtables - 16/03/06 05:14 PM
Order (sort) based on what?
Item names? Data values? Item creation dates? The Blue Fairys Diary? smile
Posted By: krunch Re: hashtables - 16/03/06 08:58 PM
time added so first added is first showen
Posted By: DaveC Re: hashtables - 16/03/06 09:29 PM
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
© mIRC Discussion Forums