next up previous contents
Next: Initialization of dotdotfiles Up: dotdot files Previous: Example

Referencing variables in other configuration files

  In the Init function, Change function, PageEnd function, ShowPage function and save function it is possible to see variables from other configuration pages. This means that you can read and write them, and enable/disable the elements they belong to.

Ordinary variables

The variables are referred to as function name@variable name. If you eg. have a variable called count on the menupage backup, then you can do the following:

Remember braces arround the variable name, when you read, since @ is a variable delimiter in TCL.

If the variable is an associative array ( Menu, Radio, ListBox), ComboBox the TCL syntax is a bit different, when you read the variable:

Variable in extentries

If the variable is in an extended entry, you have to do a forevery on the variable with the function@ prefix, and the variables will be named with the function@ prefix too. If we say we have an extentry called alias on the menupage misc, and it consists of name and value, then it could look like this:

  forevery misc@alias {
    if {${misc@name} == ""} {
      Disable misc@value
    }
  }

Variable in fillOut

If you want to refer to a fillOut element on another page, the save, change, pageEnd and init functions, foreach fillOutElm, have to be a bit different from what we already have learned.

Instead of just referring to the variable, you have to write [expand variable_name] and for associative arrays [expand variable_name variable_index]. Here's an example which will clarify the matter.

  CheckBox checkbox -text "Just a checkbox"
  Radio radio \
    -text radio -entries { "option 1" "option 2"}

  FillOutElm fill -entries checkbox radio \
    -save {
      if {[expand checkbox] == 1} {
        print "radio = [expand radio name]"
      }
    }

If referencing to this page wasn't nessecary, you could just have written:

  FillOutElm fill -entries checkbox radio \
    -save {
      if {$checkbox == 1} {
        print "radio = $radio(name)"
      }
    }



Jesper Kjær Pedersen <blackie@imada.ou.dk>
Wed Oct 2 13:29:53 MET DST 1996