This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

small trouble with writeing to a file from dcc

Old posts that have not been replied to for several years.
Locked
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

small trouble with writeing to a file from dcc

Post by SmokeyOne »

I'm not sure the right syntax for writeing to a file from within the dcc partyline. I was thinking of something like this.

bind dcc n .dbadd dcc_dbadd

proc dcc_dbadd {idx handle uhost input} {
set file [open "$file" a]
puts $file "info in text"
close $file
}
}

I'm really not sure if this is even close to the right syntax, I'm not that good with tcl, but I'm learning as i go. Thanks in advance for any help you give me

Smokey
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

now that I think about it

Post by SmokeyOne »

now that I think about it, how would i set it to go to the end of file and write the text?
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

this is what i created

Post by SmokeyOne »

bind dcc - .dbadd dcc_dbadd
proc dcc_dbadd {idx uhost hand text dest} {
putdcc "\002New info added to the FAQ database by $nick\002"
set file "~/.faq"
set fs [open $file a+]
puts $fs "$text"
close #fs
}

now when i try to do .dbadd, it get What? you need .help.

I'm guessing maybe "uhost" shouldn't be there, but then again i'm not very good at this stuff =/.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

replace
set file [open "$file" a]

with
set file [open "$file" w]

replace
bind dcc - .dbadd dcc_dbadd

with
bind dcc - dbadd dcc_dbadd

Also you may want to read again the tcl-commands.doc file, for how to do corectly a bind for dcc..
Once the game is over, the king and the pawn go back in the same box.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Re: now that I think about it

Post by Papillon »

SmokeyOne wrote:now that I think about it, how would i set it to go to the end of file and write the text?
read what he said ceasar... set file [open "$file" w] will not add text to the end of the file, it will overwrite the whole file, set file [open "$file" a] is the right syntax if you want to add text to the end of the file
Elen sila lúmenn' omentielvo
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Oh. Seems that I've skiped an line.. I was sleepy when I typed the answer :oops: sorry.. anyway, seems that the second answer is good :) At least that I can do..
Once the game is over, the king and the pawn go back in the same box.
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

thanks

Post by SmokeyOne »

i thank you for your help, I'll give it a shot and see if it works out. if not, i messed up somewhere =/
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

okay i did change it and ya it works under dcc chat, but now I have a problem

Tcl error [dcc_dbadd]: no value given for parameter "text" to "dcc_dbadd"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Why don't you read the .doc file that I've told you to read? The answer to your question is outstretched there..

bind dcc <flags> <command> <proc>
procname <handle> <idx> <text>
Once the game is over, the king and the pawn go back in the same box.
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

you want a honest answer ? i forgot lol, sorry about that.I'll look though it, but only to get lost again =/

Well that and I was too tired to even try to read the screen anymore, knowing what the error is now I'm sure i forgot to define $text that i is why its giveing me that error.

I'll give it a go and try try try again

Thanks for the help
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

okay I read it, but i guess its not helping, I'm still getting the tcl error for $text though I thought I already defind it. am I missing a "catch" statment here or something ?
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

nevermind, I think I'm about blind as a bat, but that's okay. After sleeping for awhile and comming back to it I got it hehe even found my little bug close #fs should have been close $fs.

thanks for all the help on this.
Locked