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.

Global vars...

Old posts that have not been replied to for several years.
Locked
D
DariuZ

Global vars...

Post by DariuZ »

Hi.
my q is.
Can i make global vars in a function so that i can call them as any other
global var in another function.

This is the thing, when i start upp my bot and it joins the chans i have set it to it should go through all the chans and give them a var that holds their resp, topic. Atm i have just set it to lable the vars as top1, top2, top3 a.s.o...

Just setting them as globals aint the real prob though, cause i wanna be able to do this a bit easier , like this
foreach chan [channels] {
set a "top"
set ch [append a $nr]
global $ch
set nr [expr $nr + $nr2]
}
so it goes through all the chans and "calls" a var for every chan.
just so i don´t have to edit my script file if i make it join more chans...
Hmm anyhow hope you get what i mean heh :)
//DariuZ
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

global ch not global $ch
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

why use global var ? just do $::var and you're done
User avatar
BarkerJr
Op
Posts: 104
Joined: Sun Mar 30, 2003 1:25 am
Contact:

Post by BarkerJr »

Because, if you're going to use it multiple times, it saves keystrokes and memory. It probably also runs faster, not having to keep switching namespaces, but I'm not sure.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Not to mention older TCL versions (-> older eggdrop versions) don't support namespaces, thus you lose compatibility.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

yes but its nice to know that it works like that ;)
XplaiN but think of me as stupid
Locked