mIRC Homepage
Posted By: Nutter Hash tables and Line Breaks - 21/03/04 04:49 AM
I have a multi-line edit box (text with line breaks and stuff); how do I save it with the line breaks in tact, to a hash table? " /hadd -b hash_table name $did(100).text " doesnt work, and I dont want to have each line in a seperate section of the hash file.
Posted By: LocutusofBorg Re: Hash tables and Line Breaks - 21/03/04 09:58 AM
provided it doesn't get too long,

* read one line in the box
* add it to a variable
* add a weird character to indicate the linebreak (like ยค)
* add the next line, etc

Then when reading back you can identify the linebreaks.
Posted By: Hammer Re: Hash tables and Line Breaks - 21/03/04 10:18 AM
Probably easier would be to /filter the contents of the edit into a file, then bread the file into a &binvar and hadd -b it to the table, reversing the process when you pull it out of the hash table. This method also has the added advantage of saving all the extra spaces, blank lines and any of the weird characters you care to type, as well.

Saving
[*] [color:black]
var %filename = $+($scriptdir,$ticks,.temp)
[*] filter -if $dname ID %tempfile
[*] bread %tempfile 1 $file(%tempfile).size &file
[*] hadd -mb htable item &file
[*] remove %tempfile

Loading
[*] var %filename = $+($scriptdir,$ticks,.temp)
[*] !.echo -q $hget(htable, item, &file)
[*] bwrite %tempfile 1 $bvar(&file,0) &file
[*] filter -fo %tempfile $dname ID
[*] remove %tempfile
[/color]
Posted By: Canario Re: Hash tables and Line Breaks - 22/03/04 09:31 AM
I believe that $didtok(dialog,id,C) and /didtok can help you
Posted By: Hammer Re: Hash tables and Line Breaks - 22/03/04 09:57 AM
[$|/]didtok can approximate /filter, but doesn't retain blank lines and certainly doesn't retain leading|internal|trailing spaces. /filter does. smile
© mIRC Discussion Forums