hash table view

By shadowofthenight on Apr 19, 2005

just a snippet that allows you to view contents of a hash table you either have loaded or not, differnet switches available with this that allows you to assign whether to make/load table or save/free as well. read the info included with code below to see more details on usage

;Instructions

;if the hash table is needed to be made and loaded first
;You will see a dialog appearing asking you to locate directory containing hash table 
;you want to make and load

;if you want to make and load hash table first, then add "-z" to end
;if you don't want to free hash table at end, then add a "-x" after the z 
;space in between the -z and -x , see usage below

;if you previouslly saved the hash table as a binary file, data only or ini format
;you will need to apply the respective switches for this, hense what the <switches> is for
;-b = binary file  , -n = data read only  , -i = hash table treated like a ini file

;USAGE: /get.hash <hash table name> <switches> -z -x

;Now its very important you have 3 items after the hash table name, even if you don't want to 
;use a certain part. so any part you don't want to use, replace with a "no", see below
;USAGE; /get.hash <hash table name> no no -x

alias get.hash {
  window -ak(0) @hash
  aline @hash Item $chr(9) $chr(9) Data
  aline @hash ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  var %hash.name = $1 
  var %switches = $2
  if ( $3 == -z ) { 
    var %hashtable = $+(",$sfile($mircdir),")
    hmake %hash.name
    if ( %switches == no ) { hload %hash.name %hashtable }
    else { hload %switches %hash.name %hashtable }
  }
  var %i = 1
  while ( $hget(%hash.name,%i).item ) {
    var %item = $ifmatch , %data = $hget(%hash.name,%i).data
    aline @hash %item $chr(9) $chr(9) %data
    inc %i
  }
  if ( $4 == -x ) { hfree %hash.name }
}

Comments

Sign in to comment.
eqrunner   -  May 18, 2009

works great. i some how get away with just using /get.hash and thats it, This is exactly what I needed.

 Respond  
shadowofthenight   -  Apr 27, 2005

not sure why the extra aline was in there xtr, thanks , i prefer using temp vars DarthReven but yeah your right, there not essential, can replace the vars with $1 and $2 threwout alias

 Respond  
DarthReven   -  Apr 19, 2005

its a nice little alias but that vars aren\'t really needed

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.