;Hash data levels 0.2
;hadd <- Support quiet mode(.alias)
;$hgett <- Support the propreties($identifier().prop)
;[color:#00007F]/hadd -s[color:red]lN[/color]mbczuN <name> <item> [data | &binvar][/color]
;The [b]-l[/b] switch makes /hadd to look at N tokens after <name> like at one item.
;By Adrenalin
Alias Hadd {
if (!$regex($1,/^-(.*)l(\d)(.*)$/)) {
$iif(!$show,.) $+ hadd $1-
}
else {
var %level = $regml(2)
var %OSwitch = $remove($1,-l $+ %level)
var %item = $gettok($1-,3- $+ $calc(%level + 2),32)
var %item = $replace(%item,$chr(32),.)
var %data = $gettok($1-,$calc(%level + 3) $+ - ,32)
$iif(!$show,.) $+ hadd %OSwitch $2 %item %data
}
}
Alias Hgett {
if ($prop) var %prop = $+(.,$prop)
if ($0 == 2) return $hget($1,$2) $+ %prop
var %item = $replace($2-,$chr(32),.)
return $hget($1,%item) $+ %prop
}
Alias Hash.data.levels.Test {
echo -s Adding new hash table: Univers
hmake Univers 1
echo -s Adding a item to Univers
hadd -ml3 Univers MilkyWay Earth Moldova Adrenalin
echo -s The added item value is: $&
$hgett(Univers,MilkyWay,Earth,Moldova)
echo -s Frees the hash table
hfree Univers
}