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 

set $var with $arg ...

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


Joined: 04 Nov 2007
Posts: 6

PostPosted: Sun Nov 04, 2007 11:57 am    Post subject: set $var with $arg ... Reply with quote

Hello i wan tto know if this is possible

Code:
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 !
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sun Nov 04, 2007 12:20 pm    Post subject: Reply with quote

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?
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
wubmerlin
Voice


Joined: 04 Nov 2007
Posts: 6

PostPosted: Sun Nov 04, 2007 12:51 pm    Post subject: Reply with quote

Just for your information i just got it !

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


BY:
Code:
#NO MORE PROBLEM !!!!!!
set set_rules [string tolower [lindex $arg 0]]_rules
set set_rules [set $set_rules]
#END 


Enjoy !
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