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 code

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


Joined: 10 Apr 2006
Posts: 3

PostPosted: Tue Feb 27, 2007 9:07 am    Post subject: help with code Reply with quote

hi i have writen some code and it returns with { and } at the ends and i would like to remvoe them how todo it?

Code:

proc invite_me { nick host handle text } {
 
  global db_handle staffchan

      set sql "SELECT username, irc FROM users WHERE username='$nick'"


      set result [mysqlsel $db_handle $sql -list]

        if {$result > 0} {

            set username [lindex [split $result] 0]
            set password [lindex [split $result] 1]
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Feb 27, 2007 11:58 am    Post subject: Reply with quote

If you do not provide an explicit return value using the "return" command, your proc will exit with the return value of the last successful command within the proc (not counting conditional constructs themselves).

Your code is however somewhat confusing; is $result a list of matching records, or is it the number of records returned?

Code:
if {$result > 0} {
This suggests $result is the number of records returned from your query (being an integer).

Code:
set username [lindex [split $result] 0]
This however suggests that $result is a resultset from your query, with each field being whitespace separated (ie. not a proper tcllist). I am not familiar with the -list parameter for mysqlsel, but from what I can tell from resources on the net, it makes mysqlsel return a list of lists. Hence, split should NOT be used here.

From the bits and pieces I've managed to gather from your script and mysqltcl, I guess you should have something like this:
Code:
proc invite_me { nick host handle text } {
 global db_handle staffchan
 set sql "SELECT username, irc FROM users WHERE username='$nick'"
 set result [mysqlsel $db_handle $sql -list]
 if {[llength $result] > 0} {
  set username [lindex [lindex $result 0] 0]
  set password [lindex [lindex $result 0] 1]
 }
 ....
}

_________________
NML_375, idling at #eggdrop@IrcNET
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