| View previous topic :: View next topic |
| Author |
Message |
ache Voice
Joined: 14 Oct 2005 Posts: 14
|
Posted: Tue Nov 01, 2005 8:55 am Post subject: Help with read/write to file. |
|
|
I working on a simple greet script but have encountered some problems.
this is what the script looks like so far.
| Code: |
proc pub:checkgreet {nick uhost handle channel arguments } {
list arguments $arguments
set greet.nick [lindex $arguments 0]
set greet.channel [lindex $arguments 1]
set greet.text [lrange $arguments 2 end]
putlog "1 Greet nick: $greet.nick Greet channel: $greet.channel Greet text: $greet.text"
if {([string index $greet.channel]=="#")} {
[pub:addgreet $greet.nick $greet.channel $greet.text]
} elseif {($greet.channel=="all")} {
[pub:addgreet $greet.nick $greet.channel $greet.text]
} else {
putquick "PRIVMSG $nick : Please state a channel to greet in. \026!chelp !addgreet\026 for more info."
return
}
putlog "2 Greet nick: $greet.nick Greet channel: $greet.channel Greet text: $greet.text"
}
proc pub:addgreet {greet.nick greet.channel greet.text} {
}
proc pub:delgreet {nick uhost handle channel args } {
}
|
the error i get is this
| Code: |
Tcl error [pub:checkgreet]: syntax error in expression "($greet.channel=="all")": looking for close parenthesis
|
I cant fingure out what the problem is..
any help would be greatly appreciated.
thanks
Last edited by ache on Tue Nov 01, 2005 12:35 pm; edited 2 times in total |
|
| Back to top |
|
 |
ache Voice
Joined: 14 Oct 2005 Posts: 14
|
Posted: Tue Nov 01, 2005 9:15 am Post subject: |
|
|
Nevermind the last thing, sorted that one but got a new error.
new error:
| Code: |
Tcl error [pub:checkgreet]: wrong # args: should be "string index string charIndex"
|
new code:
| Code: |
proc pub:checkgreet {nick uhost handle channel arguments } {
list arguments $arguments
set greetnick [lindex $arguments 0]
set greetchannel [lindex $arguments 1]
set greettext [lrange $arguments 2 end]
putlog "1 Greet nick: $greetnick Greet channel: $greetchannel Greet text: $greettext"
if {([string index $greetchannel]=="#")} {
[pub:addgreet $greetnick $greetchannel $greettext]
} elseif {[string index $greetchannel]=="all"} {
[pub:addgreet $greetnick $greetchannel $greettext]
} else {
putquick "PRIVMSG $nick : Please state a channel to greet in. \026!chelp !addgreet\026 for more info."
return
}
putlog "2 Greet nick: $greetnick Greet channel: $greetchannel Greet text: $greettext"
}
proc pub:addgreet {greetnick greetchannel greettext} {
}
proc pub:delgreet {nick uhost handle channel args } {
}
|
|
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
|
| Back to top |
|
 |
ache Voice
Joined: 14 Oct 2005 Posts: 14
|
Posted: Tue Nov 01, 2005 9:50 am Post subject: |
|
|
Thanks Alchera
found the problem.  |
|
| Back to top |
|
 |
ache Voice
Joined: 14 Oct 2005 Posts: 14
|
Posted: Tue Nov 01, 2005 12:31 pm Post subject: |
|
|
Got a new problem.
this is the code so far (i know it ainīt much):
| Code: |
proc pub:addgreet {nick greetnick greetchannel greettext} {
set greetdb "scripts/greets.db"
set greetdbtmp "scripts/greets.db.tmp"
}
|
Anyway. what iīm after is a process that searches a file (greets.db) for $greetchan $greetnick and if it finds it will replace it with $greetchan $greetnick $greettext. If it doesnīt find it it will just add the line at the bottom of the file.
I know this might be abit much to ask but i canīt seem to get anywhere with it.
thanks. |
|
| Back to top |
|
 |
|