Variables

You can access the Variables tab of the script center in three ways:

In the variables tab you can see all the variables (and their values) of the ::IRC name space, when using 'variable' instead of 'global' to bring the variable into scope.

If a scripting procedure creates a variable in the IRC name space or simply changes the value of a variable in the IRC name space you will see the variable with it's updated value in the variable tab.

Lets say that you have the following procedure in one of your script files, like functions.tcl

proc SetServer {} {
  variable svr ;# Variable MUST be used instead of global
    set svr "irc.tin.it"
}
		

Now when SetServer is executed, the variable name and its value will show up in the variables.tcl file. If "svr" already exists, SetServer will simply set it's new value, otherwise a new variable called "svr" will be created inside the ::IRC name space. In both cases the "svr" variable and it's value will be visible in the variable tab.

In the left part of the variable tab a Tree widget displays all the variables grouped in the ::IRC name space. The Tree widget groups together all the variables of the same array and displays the array name near the "+" button. If you click on the "+" button the group is expanded and you can see all of the variables in the array.

By clicking on a variable name the variable gets selected in the text widget in the right part of the variable tab.

Setting variables. 

In the variable tab you can also set new variables. To set a variable just do it as you would normally do in TCL: use the "set" command.

For arrays instead there is a little difference: you don't need to create or to initialize an empty array (using the TCL "array" command) before being able to use it: savIRC does this for you. For example you can simply write:

set net(server) "irc.tin.it"
set net(port) "6667"
		

And an array called "net" is automatically created, you don't need to create it.

As explained before, you can access and use the variables in your procedures and events by using the 'variable' command. The example below shows how to create an on join event that sends a message to all people joining a channel you will want to put this in your variables.tcl file.

set joinMsg "Hello, visit this website: http://www.savirc.com"
		

Then create a on join event, as described in Events. Import the 'joinMsg' variable in the event using the 'variable' command; the event will look like this:

on join * {
   variable joinMsg
   msg $nick $joinMsg
}
		

When testing this script you'll see that every nick that joins the channel (including yourself) will get the message.