Setting the Window Formula

 

The previous dialog boxes that generate a series place the series in the current window, however, the window formula is not updated to reflect the series formula. The SETWF function and := window assignment operator can be used to set the formula. For example, the following panel generates user specified random noise in the current window and sets the window formula:

 

// winform1.pan

@dialog

 

// initialize input parameters

{defvar("wlen", 100);defvar("wspc", 0.01)}

 

Generate Noise

 

Length:  <w=20>~setvar("wlen", <{wlen}>)~input(2)

Spacing: <w=20>~setvar("wspc", <{wspc}>)~input(1)

<L>

~menuclear

~setwf(W0, sprintf("grand(%d, %g)", wlen, wspc))

 

 

 

To construct the formula, SPRINTF converts the variable values to string values substituting the values into the % fields.  The %d option implies an integer value and %g implies a real value.

 

SETWF assigns the string returned by SPRINTF to the window formula of the specified window. In this case, W0 refers to the current window. SETWF without a window argument also defaults to the current window.

 

 

Because SETWF also evaluates the formula, both the formula and the noise series are placed in the current window.

 

The panel can also be written to use the := window assignment operator:

 

// winform2.pan

@dialog

 

// initialize input parameters

{defvar("wlen", 100);defvar("wspc", 0.01)}

 

Generate Noise

 

Length:  <w=20>~setvar("wlen", <{wlen}>)~input(2)

Spacing: <w=20>~setvar("wspc", <{wspc}>)~input(1)

<L>

~menuclear

~eval(sprintf("W0 := grand(%d, %g)", wlen, wspc))

 

In this case, SPRINTF constructs the assignment formula and EVAL evaluates the assignment. Like SETWF, the := operator assigns the formula and resulting series to the specified window.