List Box Options as an Enumerated List


In the previous examples, the options selected in a list box specified in variables as strings, i.e. the name of the option.  In some cases it may be more convenient to test a numeric value, rather than parse the string name.  To indicate that the list box options be interpreted as an enumerated list, place an n character in the display area of the menu file between the angle braces < >.  By default, an enumerated list starts with zero (0), and follows the order in which the options are placed in the list.  The starting value can be set by providing a value for the n flag, such as n=2.


Enumerated lists are particularly helpful when there are many choices, and the menu calls an SPL function that contains switch case statements.  


The following menu contains a simple example of using an enumerated list in a listbox.  


// listbox3.pan



Sample Enumerated Type


Output Form <n w=30>~outf=< >~<Real Imaginary><Magnitude Phase>



~if(outf, setwf("FFTP(W1)"), setwf("FFT(W1)"))




If Real Imaginary is selected, the value 0 is substituted and assigned to outf and if Magnitude Phase is selected, the value 1 is assigned to outf. The 0 or 1 value is used by the if function to determine the form of the FFT to compute and assign to W1.