This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

SELECT 2 args instead of 1

Help for those learning Tcl or writing their own scripts.
Post Reply
P
Psyfire
Voice
Posts: 36
Joined: Sun Nov 05, 2006 12:32 pm

SELECT 2 args instead of 1

Post by Psyfire »

Hello,

this is my code:

Code: Select all

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?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

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: Select all

foreach {arg1 arg2} [split $arg] {break}
after the 'global' line.
P
Psyfire
Voice
Posts: 36
Joined: Sun Nov 05, 2006 12:32 pm

Post by Psyfire »

Wow, really easy, thank you Sir :-)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

If you want to make sure that the 2 args exist before continuing, use this instead:

Code: Select all

if {[scan $arg {%s %s} arg1 arg2]!=2} {return 0}
# continue with $arg1 and $arg2
Post Reply