mIRC Home    About    Download    Register    News    Help

Print Thread
#76021 21/03/04 04:49 AM
Joined: Jan 2004
Posts: 18
N
Nutter Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: Jan 2004
Posts: 18
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.


Nutter
GameSurge IRC Network
www.gamesurge.net
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
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.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
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]


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Joined: Nov 2003
Posts: 67
C
Babel fish
Offline
Babel fish
C
Joined: Nov 2003
Posts: 67
I believe that $didtok(dialog,id,C) and /didtok can help you


irc.universochat.net
#escripting
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
[$|/]didtok can approximate /filter, but doesn't retain blank lines and certainly doesn't retain leading|internal|trailing spaces. /filter does. smile


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C

Link Copied to Clipboard