[color:green]; delhole: delete a hole in a numerically sorted hashtable
; usage: /delhole [table] [N][/color]
alias delhole {
[color:green]; I need one numerical parameter and a table name ![/color]
if (!$1) || (!$2) || ($3) {
echo -a [color:red]Syntax error: Alias delhole accepts exactly two arguments, and not $0 $+ .[/color]
echo -a [color:red]Correct usage: /delhole table N[/color]
}
elseif (!hget($1)) {
echo -a [color:red]Syntax error: The supplied hash table does not exist.[/color]
}
elseif ($2 !isnum) {
echo -a [color:red]Syntax error: Argument 2 must be a number representing the hole in the table.[/color]
}
else {
[color:green]; set start and end of loop[/color]
var %i = $2,%j = $hmatch($1,*,0)
[color:green]; start loop[/color]
while (%i <= %j) {
hadd $1 %i $hget($1,$calc(%i + 1))
inc %i
}
[color:green]; delete final entry[/color]
hdel $1 $calc(%j + 1)
echo -a [color:blue]sequence complete[/color]
}
}