Whats wrong with this hash table? - 20/11/08 11:11 AM
I can add channels to the table, i can also remove channels from the table, but it won't halt if the #channel don't exist in the table, it says:
-> Channel "#channel" removed successfully.
but it cant have been removed successfully since it wasn't in the table, how to get around this? and can the code be made smaller? I didn't add the dialogs since they only add the value to the %var i use, and then trigger the script when i press the button.
-> Channel "#channel" removed successfully.
but it cant have been removed successfully since it wasn't in the table, how to get around this? and can the code be made smaller? I didn't add the dialogs since they only add the value to the %var i use, and then trigger the script when i press the button.
Code:
on *:start: { if (!$hget(prot.channels)) { .hmake -s prot.channels 1000 } if ($exists(scripts\hash\channels.hsh)) { hload prot.channels scripts\hash\channels.hsh } } alias add-prot-chan { if (%add.prot.chan == $null) { echo -a -> You need to enter a channel to add first. | return } var %add_prot_chan = $replace($strip(%add.prot.chan),$chr(44),$chr(32)), %a = 1, %b = $numtok(%add_prot_chan,32) while %a <= %b { var %add.prot.chan = $gettok(%add_prot_chan,%a,32) if $hget(prot.channels,%add.prot.chan) { echo -a -> The channel $qt(%add.prot.chan) already exists in the list. } else { .hadd -m prot.channels %add.prot.chan echo -a -> The channel $qt(%add.prot.chan) added successfully } inc %a } } alias rem-prot-chan { if (%rem.prot.chan == $null) { echo -a -> You need to enter a word to remove. | return } if (%rem.prot.chan == No channels) { echo -a -> That text can't be removed. | return } if (!$hget(prot.channels,%rem.prot.chan).item) { echo -a -> The channel $+($chr(34),%rem.prot.chan,$chr(34)) does not exist in the list. } if ($hget(prot.channels,%rem.prot.chan).item) { hdel prot.channels %rem.prot.chan | echo -a -> channel $+($chr(34),%rem.prot.chan,$chr(34)) removed successfully. | loadprotchannels } }