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 

SELECT 2 args instead of 1

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


Joined: 05 Nov 2006
Posts: 36

PostPosted: Fri May 04, 2007 12:59 pm    Post subject: SELECT 2 args instead of 1 Reply with quote

Hello,

this is my code:

Code:

proc amxx:db:info {nick host hand chan arg} {
                  global sql

               set sql(handle) [mysqlconnect -host $sql(host7) -user $sql(user7) -password $sql(pass7) -db $sql(db7)]
               set sma(qry) [mysqlsel $sql(handle) "SELECT blafield,blafield2 FROM blatable WHERE bla1 = '$arg1' AND bla2 = '$arg2'" -flatlist]
               mysqlclose $sql(handle)

                  if {$sma(qry) != ""} {

               set gelesen(blafield) [lindex $sma(qry) 0]
               set gelesen(blafield2) [lindex $sma(qry) 1]



         putserv "PRIVMSG $chan :»» PlayerID: $gelesen(blafield) and $gelesen(blafield2)"


            
      }


I want there to select 2 args. Its like I write this into the channel:

Psyfire: !get arg1 arg2
Bot: Arg1=Test and Arg2=Bla

What do I have to modify, to search 2 args and output them correctly?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri May 04, 2007 1:15 pm    Post subject: Reply with quote

Ok, so your problem is in getting arg1 and arg2? well if it's a pub bind then all you need is to add
Code:
foreach {arg1 arg2} [split $arg] {break}

after the 'global' line.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Psyfire
Voice


Joined: 05 Nov 2006
Posts: 36

PostPosted: Sun May 06, 2007 7:23 am    Post subject: Reply with quote

Wow, really easy, thank you Sir Smile
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 06, 2007 8:11 am    Post subject: Reply with quote

If you want to make sure that the 2 args exist before continuing, use this instead:
Code:
if {[scan $arg {%s %s} arg1 arg2]!=2} {return 0}
# continue with $arg1 and $arg2

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
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