next up previous contents
Next: The Save funktion Up: The InitChange, ShowPage and PageEnd Previous: Visual variables

Example

Let's try to see the following page:

  CheckBox cb1 -text cb1
  CheckBox cb2 -text cb2
  CheckBox cb3 -text cb3
  CheckBox cb4 -text cb4
  
  ExtEntry ee1 -entries cb1 -count 2
  ExtEntry ee2 -entries cb2 cb3 ee1 -count 2 \
      -subFrame:bd 1 -subFrame:relief sunken

This looks like this:

tex2html_wrap1519


The following is then true:

The Change function may look like this:

  switch $changeElm {
    cb4 {
      [pick $cb4 Enable Disable] ee2
    }
    cb2 {
      forevery ee1 {
        set cb1 $cb2  
      }
     }
    cb1 {
      if {$cb1 == 1} {
        set cb3 1
      }
    }
  }

This is a quite complicated function, but let's see what happens for each element. The switch function selects one of the following based on which element is the one changed:

cb4
If cb4 is the changed element, then the following line is evaluated: [pick $cb4 Enable Disable] ee2. The first part just selects Enable if $cb4 is true and Disable if it is false. The whole line enables ee2 if cb4 is checked, otherwise it disables ee2 (This is an example of how you can enable/disable an extentry.)
cb2
If cb2 is selected then all the cb1's are set according to cb2 (This is an example of the use of forevery in the Change function.)
cb1
If one of the cb1 is checked then cb2 is also checked. NOTE: This is ok since I must reference up, but it was not ok in the previous, since this would have been a refence down, and that's not allowed!

NOTE: This example is included in the demo packages.



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