egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with read/write to file.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ache
Voice


Joined: 14 Oct 2005
Posts: 14

PostPosted: Tue Nov 01, 2005 8:55 am    Post subject: Help with read/write to file. Reply with quote

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
View user's profile Send private message
ache
Voice


Joined: 14 Oct 2005
Posts: 14

PostPosted: Tue Nov 01, 2005 9:15 am    Post subject: Reply with quote

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
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Nov 01, 2005 9:37 am    Post subject: Reply with quote

Tcl Built-In Commands - string manual page
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
ache
Voice


Joined: 14 Oct 2005
Posts: 14

PostPosted: Tue Nov 01, 2005 9:50 am    Post subject: Reply with quote

Thanks Alchera
found the problem. Smile
Back to top
View user's profile Send private message
ache
Voice


Joined: 14 Oct 2005
Posts: 14

PostPosted: Tue Nov 01, 2005 12:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber