| View previous topic :: View next topic |
| Author |
Message |
Psyfire Voice
Joined: 05 Nov 2006 Posts: 36
|
Posted: Fri May 04, 2007 12:59 pm Post subject: SELECT 2 args instead of 1 |
|
|
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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri May 04, 2007 1:15 pm Post subject: |
|
|
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 |
|
 |
Psyfire Voice
Joined: 05 Nov 2006 Posts: 36
|
Posted: Sun May 06, 2007 7:23 am Post subject: |
|
|
Wow, really easy, thank you Sir  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun May 06, 2007 8:11 am Post subject: |
|
|
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 |
|
 |
|