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.

set $var with $arg ...

Help for those learning Tcl or writing their own scripts.
Post Reply
w
wubmerlin
Voice
Posts: 6
Joined: Sun Nov 04, 2007 11:50 am

set $var with $arg ...

Post by wubmerlin »

Hello i wan tto know if this is possible

Code: Select all

bind pub - !rules pub_rules

set public_rules "test public"
set private_rules "test private"
set pm_rules "test pm"

proc pub_rules { nick uhost hand chan arg } {
global public_rules pm_rules private_rules

if {[string tolower [lindex $arg 0]] != ""} {

#HERE IS MY PROBLEM !!!!!!
set set_rules $[string tolower [lindex $arg 0]]_rules
#END OF PROBLEM

puthelp "PRIVMSG $chan :[string toupper [lindex $arg 0]] Rules"
puthelp "PRIVMSG $chan :$set_rules"

}
I want to grabmy var with the arg, example if i type !rules public

$arg = public
i want to set:
set set_rules $$arg
Like this : set set_rules $public_rules

And i dont want set it with if $arg == public ... i want it like this b/c i have 250 rules to set and i want to clean my code ( already done with the IF )

Thanks alot !
User avatar
CrazyCat
Revered One
Posts: 1334
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I think that you can have a solution with eval or subst, but I can't give you the correct syntax you need.
Peharps anyone else?
w
wubmerlin
Voice
Posts: 6
Joined: Sun Nov 04, 2007 11:50 am

Post by wubmerlin »

Just for your information i just got it !

REPLACE:

Code: Select all

#HERE IS MY PROBLEM !!!!!! 
set set_rules $[string tolower [lindex $arg 0]]_rules 
#END OF PROBLEM 
BY:

Code: Select all

#NO MORE PROBLEM !!!!!! 
set set_rules [string tolower [lindex $arg 0]]_rules
set set_rules [set $set_rules]
#END  
Enjoy !
Post Reply