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.

Passing on a variable outside a proc

Help for those learning Tcl or writing their own scripts.
Post Reply
M
Mr B
Voice
Posts: 2
Joined: Fri Oct 05, 2007 2:42 pm
Location: a secret bunker

Passing on a variable outside a proc

Post by Mr B »

I just started learning tcl and came across a couple things I just couldn't find any answers to.
Here goes:

Code: Select all

bind pub - !test lineread
proc lineread {nick host handle chan text} {
  global prech homech
  if {$chan == $homech} {
  putserv "PRIVMSG $prech :$text" }
My first question is, is it possible to pass a variable from one procedure onto another procedure (without using a file) and how qould that work
In this case the content of $text, since I want to use it in my second procedure.

-
My second procedure will read a specific line, which starts with [
My first thought was to use the \[*

Code: Select all

bind pubm - "$prech \[*" reread 
which obviously doesn't work since the [ is in bold
after that I also tried /002\[ to no avail

Code: Select all

bind pubm - "$prech /002\[*" reread 
My question is, is there a way to get this to work in the bind pubm line.

Thanks in advance
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

1: Check out the global command.
Obviously you are already using it, probably just need to read alittle to figure out how to use it.

2: Use \ooo or \xhh to create any character, not /ooo or /xhh (ooo being the octal value, such as 002, xhh being hexadecimal value, such as x02).
Thus, this should do the trick:

Code: Select all

bind pubm - "$prech \002\[*" reread
NML_375
M
Mr B
Voice
Posts: 2
Joined: Fri Oct 05, 2007 2:42 pm
Location: a secret bunker

Post by Mr B »

Ok it took me a bit cause I made some mistakes at first but I finally saw the light
passing on using the global command works now :)

Thanks for pushing me in the right direction nml375 and for the explantion on the second problem, that also works like a charm now
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

That's why we're here :)
NML_375
Post Reply