Dynamically Updating Tabbed Dialog Boxes

 

The # modifier allows a standard dialog box to change in response to user input. For a tabbed dialog box, the # modifier only effects the current tab. Use the ## modifier to update the entire tabbed dialog box.

 

For example, we can modify the previous tabbed dialog box to hide the horizontal units field of the units tab when the Normal option is selected in the generate tab.

 

// tabbed2.tab - tabbed dialog box

@tabbed

 

Tabbed Dialog Box

 

~_menuf("gen2.pan")

~_menuf("units2.pan")

 

// statements to execute on OK

~~unitfun = sprintf("setvunits('%s');sethunits('%s')", vunits, hunits);

~~if(_chkwin > 0, eval(sprintf('setwf(%s, "%s;%s")', _dwin, gfunc, unitfun)))

 

// gen2.pan - generate data

@dialog

 

// default values

{defvar("dist", 0);defvar("len", 100);defvar("dx", 0.01)}

 

Generate Random Data

Distribution <## r n>~dist = <{dist}>~<Uniform><Normal>

Length:      <w=20>~len = <{len}>~input(2)

Delta X:     <w=20>~dx  = <{dx}>~input(1)

<L>

{_dwinstrS("w=20")}

~_verifydlen

~if(dist==0, gfunc = "Grandom", gfunc = "Gnormal")

~gfunc = sprintf("%s(%d, %g)", gfunc, len, dx)

 

// units2.pan

@dialog

 

// default units to system defaults

{defvar("vunits", _getvunits);defvar("hunits", _gethunits)}

 

Units

<>

(Y) Vertical Units:   <* w=20>~vunits="<{vunits}>"~_unitslist

(X) Horizontal Units: <* w=20 v={not(dist)}>~hunits="<{hunits}>"~_unitslist

<L>

 

 

 

 

If Normal is selected in the generation tab, the Horizontal Units option of the units tab is hidden:

 

 

 

 

Because the ## modifier in gen2.pan causes the entire tabbed dialog box to update when the Distribution radio button changes, the units2.pan tab can respond to the change.