Adding Custom Help

 

The @h option adds user-defined help to any menu or dialog box. For example, the line:

 

@h panel.chm

 

registers "panel.chm" as the help file for any dialog box in which it was included. The @h option automatically adds the Help button to the menu or dialog box. The help file pops up whenever the user clicks on the Help button or presses [F1].

 

The help option can also specify a specific function to run when the Help button is pressed.

 

@h~viewhtml("myhelp.htm")

 

The HTML file myhelp.htm is displayed when the help button is pressed.

 

@h~help("gnormal")

 

In this case, the built-in help for the GNORMAL function is displayed when the help button is pressed.

 

The following form uses dynamic updating and an SPL function to display the help information based on the selected generation function.

 

// form2.pan - form based dialog

@panel

@form

@h~help(form_getfunc(_form_func))

 

// default initial func, length and deltax if not defined

{defvar("_form_func", 0)}

{defvar("_form_dlen", 1000)}

{defvar("_form_dx",   0.01)}

 

Generate Data

 

// data, horizontal radio buttons

Series Type   <% r h n w=20>~_form_func = <{_form_func}>~<Uniform Noise><Normal Noise><Sinusoid>

// get integer value, "%" sets value immediately

 

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

// get real value, "%" sets value immediately

 

DeltaX: <% w=20>~_form_dx   = <{_form_dx}>  ~input(1)

<L>

{_dwinstrS("w=20")}

<L>

// generate data when OK pressed

~form_gendata(_form_func, _form_dlen, _form_dx, _dwin)

 

@endform

 

// SPL code

 

form_getfunc(type)

{

    local func;

 

    // get generator function

    switch (type)

    {

        case 0:

        default:

            func = "Grandom";

            break;

        case 1:

            func = "Gnormal";

            break;

        case 2:

            func = "Gsin";

            break;

    }

    return(func);

}

 

form_gendata(type, len, dx, win)

{

    local func;

    

    func = form_getfunc(type);

    // format and set the current window formula

    eval(sprintf("%s := %s(%d, %g)", win, func, len, dx));

}

 

 

 

Because the % modifier is specified, the _form_func variable is immediately assigned an integer value that represents the desired generation function. The func_getfunc() function converts the integer to a function string. This string is used to display the appropriate built-in in help information. The displayed information depends on the selected Series Type option.