LAST PAGE  BACK TO INDEX  NEXT PAGE

[5.0] VEE Input & Display Objects

[5.0] VEE Input & Display Objects

v5.0 / 5 of 23 / 01 sep 99 / gvg

* This chapter outlines the tools provided by VEE for user input and data display.


[5.1] ELEMENTARY INPUT OBJECTS
[5.2] KEYBOARD CONTROL OVER VEE PROGRAMS
[5.3] POP-UP DIALOGS
[5.4] ELEMENTARY OUTPUT OBJECTS
[5.5] VEE GRAPH OBJECTS
[5.6] USING SHOWPANEL() & HIDEPANEL() / NONMODAL DIALOGS
[5.7] SHOWPANEL() & HIDEPANEL EXAMPLES

 BACK TO INDEX

[5.1] ELEMENTARY INPUT OBJECTS

* Data constants can be used as simple user-input devices, though error-handling can be tricky if the user provides an incorrect input. Pop-up dialogs can be used if that is a problem, as one of the following sections will discuss. Note that as of VEE 3.X, Text Constant objects could handle "password masking"; this means that if the user types in "HI THERE" all that is shown in the object is "********".

As you should now know by now, VEE offers two elementary button objects, the Start button -- which allows you to initiate an action -- and the OK button -- which allows you to hold off an action until it's selected.

* VEE also provides a set of Toggles objects (a set that was greatly expanded in VEE 3.X). The Toggle objects define two-position switches, and generate a 1 or 0 depending on the switch setting.

You can not only select from a variety of useful predefined Toggle appearances -- a simple button or check box (its only appearances in versions before 3.X), or Paddle, Rocker, or Slide switches in both vertical and horizontal orientations -- but you can make a custom switch by providing it with two bitmaps, one for the "on" state and one for the "off".

If you select one of the predefined Toggle objects, pull down its object menu, and select its "Edit Properties" menu, you get a tab folder:


   +----------------------------------------------------------------+
   |                       Default Preferences                      |
   +------------+------------+------------+------------+------------+
   |  General   |   Colors   |    Fonts   |   Custom   |    Icon    |
   |            +------------+------------+------------+------------+
   |  Title: [V.Paddle                   ]                          |
   | +- Open View --------+ +- Debug ----------------+              |
   | | [ ] Show Title Bar | | [ ] Breakpoint Enabled |              |
   | | [ ] Show Terminals | |                        |              |
   | +--------------------+ +------------------------+              |
   | +- Format ---+ +- Execution --------+ +- Initialization -----+ |
   | | Button     | | [x] Wait for Input | | Initial Value: [ 0 ] | |
   | | Check Box  | | [ ] (Auto Execute) | | [ ] Init at PreRun   | |
   | | V Paddle   | +--------------------+ | [ ] Init at Activate | |
   | | H Paddle   | +- Layout -----------+ |                      | |
   | | V Rocker   | | [ ] Scaled         | |                      | |
   | | H Rocker   | | [x] Show Caption   | |                      | |
   | | V Slide    | |                    | |                      | |
   | | Hal Slide  | |                    | |                      | |
   | | <Custom>   | |                    | |                      | |
   | +------------+ +--------------------+ +----------------------+ |
   +----------------------------------------------------------------+
   |                [   OK   ] [ Cancel ] [  Help  ]                |
   +----------------------------------------------------------------+
 
Most of the stuff is more-or-less typical of any object menu -- Colors, Fonts, and Icon settings, fields for setting debugging, option, and layout options -- but there are a few special fields in this case. First, you can set the Toggle to "Wait for Input" -- in which case the Toggle will not generate an output until you actually click on it with a mouse.

Second, you can select the Toggle style -- Button, Check Box, Paddle, and so on -- which is no big deal since you have access to the different styles from the VEE menu, except for the "<Custom>" entry, which allows you to build your own Toggle style. Click on this and then select the "Custom" tab in the tab folder and you get:


   +----------------------------------------------------------------+
   |                       Default Preferences                      |
   +------------+------------+------------+------------+------------+
   |  General   |   Colors   |    Fonts   |   Custom   |    Icon    |
   +------------+------------+------------+            +------------+
   | +- On Picture -------------------+- Preview -+                 |
   | | exclam.gif                     |           |                 |
   | +----------------+---------------+           |                 |
   | | (None)         | +-----------+ |           |                 |
   | | arrow.gif      | | Browse... | |     !     |                 |
   | | basic.icn      | +-----------+ |           |                 |
   | | beep.icn       |               |           |                 |
   | +----------------+---------------+-----------+                 |
   | +- Off Picture ------------------+- Preview -+                 |
   | | question.gif                   |           |                 |
   | +----------------+---------------+           |                 |
   | | (None)         | +-----------+ |           |                 |
   | | arrow.gif      | | Browse... | |     ?     |                 |
   | | basic.icn      | +-----------+ |           |                 |
   | | beep.icn       |               |           |                 |
   | +----------------+---------------+-----------+                 |
   +----------------------------------------------------------------+
   |                [   OK   ] [ Cancel ] [  Help  ]                |
   +----------------------------------------------------------------+
 
This panel allows you to select and preview a pair of bitmap files that will be alternately displayed in the Toggle in its On and Off states. The files can be GIF, Windows BMP, or X11 ICN files.

* The various List, or "Selection Control" objects -- whose variety was also expanded in VEE 3.X -- allows selection from a list and returns the list selection. The List objects can be configured as a set of Radio Buttons, Cyclic Button, List, Drop-Down List and Pop-Up List, as specified by the object menus.

The Slider objects allow a user to set either Integer or Real values using a mouse. Integer and Real Knob objects were added in VEE 3.1, but they are really just modified versions of the Sliders. The Knobs provide you with a simulated front-panel knob that you can "twirl" by clicking on the direction you want the knob to go with your mouse, or by grabbing the hairline indicator and moving the knob around with a click-and- drag operation.

The Knobs' "Edit Properties" tabfolder is typical of this set of objects and gives the following options:


   +----------------------------------------------------------------------+
   |                            Knob Properties                           |
   +--------------+-------------+-------------+-------------+-------------+
   |   General    |   Colors    |    Fonts    |   Custom    |    Icon     |
   |              +-------------+-------------+-------------+-------------+
   |  Title: [IntKnob                    ]                                |
   |                                                                      |
   | +- Open View --------+ +- Debug ----------------+                    |
   | | [x] Show Title Bar | | [ ] Breakpoint Enabled |                    |
   | | [ ] Show Terminals | |                        |                    |
   | +--------------------+ +------------------------+                    |
   | +- Format ---------+ +- Execution --------+ +- Initialization -----+ |
   | | <*> Horizontal   | | [x] Wait for Input | | Initial Value: [ 0 ] | |
   | | < > Vertical     | | [ ] (Auto Execute) | | [ ] Init at PreRun   | |
   | | [x] Show Display | |                    | | [ ] Init at Activate | |
   | | Detents: [1    ] | |                    | |                      | |
   | +------------------+ +--------------------+ +----------------------+ |
   +----------------------------------------------------------------------+
   |                   [   OK   ] [ Cancel ] [  Help  ]                   |
   +----------------------------------------------------------------------+
 
You can set the orientation of the Knob; whether it has numeric display indicators; the size of the "detent" values -- that is, the interval by which you can set values on the Knob (its resolution, or granularity, in other terms); whether it waits for input or not; and initial values.

Control inputs may be added for Default Value, Reset, MaxValue, MinValue, and Detents. If you want to play with these tools, check out the example programs xlsttog.vee (List and Toggle objects) and xknbinc.vee (Knob & Indicator objects)

 TOP OF PAGE

[5.2] KEYBOARD CONTROL OVER VEE PROGRAMS

* VEE 3.0 added the ability to control a VEE program from the keyboard. Programs can be run and controlled via the following control key sequences:


   CTRL-G:    run program
   CTRL-V:    continue
   CTRL-T:    step
   CTRL-C:    stop program 
 
You can use the Tab key to move around a user interface, skipping from input object to input object. Shift-Tab moves you backwards. You can select a button by pressing the space bar.

The most useful element for building such a user interface is the OK button. Not only is its operation more straightforward than other input devices, but it has a special feature that make it suited to the role: you can assign an OK button to a function key, the Enter key, or the Escape key.

You can configure this feature by bringing up the OK button's object menu:


   +----------------------------------------------------------------+
   |                         OK Properties                          |
   +----------------+---------------+---------------+---------------+
   |     General    |    Colors     |     Fonts     |     Icon      |
   |                +---------------+---------------+---------------+
   |  Title: [ OK                        ]                          |
   | +- Open View ---------+ +- Debug ----------------+             |
   | | [x] Show Title Bar  | | [ ] Breakpoint Enabled |             |
   | | [ ] Show Terminals  | |                        |             |
   | +---------------------+ +------------------------+             |
   | +- Function Keys ------------+ +- Panel View Operation ----+   |
   | | [x] Assign to Function Key | | [ ] Assign to [Enter] Key |   |
   | | [           F1           ] | | [ ] Assign to [Esc] Key   |   |
   | +----------------------------+ +---------------------------+   |
   +----------------------------------------------------------------+
   |                [   OK   ] [ Cancel ] [  Help  ]                |
   +----------------------------------------------------------------+
 
You set the appropriate flags to assign a function key, the Enter key, or the Escape key to the button. Note that you could in principal assign a function key, the Enter key, and Escape key to the same OK button, though all three don't make much sense. Generally you want to assign the Enter key to one (and only one) "default" button (possibly also mapped to a function key), and assign the Escape key to some "emergency" button (also possible mapped to a function key.

The following program (see xkbtest.vee for the source) demonstrates how to use keyboard input through a set of OK buttons. All it does is allow you to press buttons and get a different text output in an AlphaNumeric display object:


   +-------+
   | Until |
   | Break +--------+
   +-------+        | OK
	       +----+----+
               | F1:Key1 +---------------------+
               +---------+                     |
   +-------+                +------------------+-----------------+
   | Until |                |  Message Box: "This is task one!"  |
   | Break +--------+       +------------------------------------+
   +-------+        | 
	       +----+----+
               | F2:Key2 +---------------------+
               +---------+                     |
   +-------+                +------------------+-----------------+
   | Until |                |  Message Box: "This is task two!"  |
   | Break +--------+       +------------------------------------+
   +-------+        | 
	       +----+----+
               | F3:Key3 +---------------------+
     OK        +---------+                     |
   +-------+                +------------------+-----------------+
   | Quit  +----+           | Message Box: "This is task three!" |
   +-------+    |           +------------------------------------+
                |
            +---+---+
            | Stop  |
            +-------+
 
The keys are assigned as follows:

   [ F1:Key1 ]      F1 function key and Enter key.
   [ F2:Key2 ]      F2 function key.
   [ F3:Key3 ]      F3 function key.
   [ Quit ]         Escape key.
 
A panel view for the program can be set up as follows:

   +---------+  +---------+  +---------+
   | F1:Key1 |  | F2:Key2 |  | F3:Key3 |
   +---------+  +---------+  +---------+
   
          +-------------------+
          |    AlphaNumeric   |
          +-------------------+
          | This is task one! |
          +-------------------+

                 +------+
                 | Quit |
                 +------+
 
You can press CTRL-G to run the program, use Tab and Shift-Tab to move among the OK buttons, and select a function with the Space bar. You can select any of the three buttons at top by pressing the appropriate function key. If you press Enter, you get the default button, which is "[F1:KEY1]". If you press the Escape key, you quit the program.

It is recommended that the OK buttons and dialog boxes be used to set up the keyboard-controlled user interface; other input devices can be used, but suffer from a number of limitations:

It is not recommended that you set up multiple threads in programs designed for keyboard control! They can be made to work but getting them to do so is counterproductively tricky.

 TOP OF PAGE

[5.3] POP-UP DIALOGS

* VEE 3.X introduced pop-up dialog objects. While you could build popup dialogs in earlier versions of VEE, assembling a dialog by hand was a pain and something better was needed.

The Message Box allows you to pop up standard Windows-style alert dialogs. It is configured with an object with the format:


   +---------------------------------------+
   |              Message Box              |
   +------------------------------+--------+
   | Message  [ User Message    ] |   OK   |
   | Symbol   (i) [ information ] |        |
   | Buttons  [    OK Cancel    ] | Cancel |
   | Default  [       OK        ] |        |
   +------------------------------+--------+
 
This object allows you to provide:

The message, symbol, and default button can be set programmatically by bringing out input pins to the object. You can also use the object's "Edit Properties" tab folder dialog to set colors, fonts, and a timeout. Setting a timeout adds another output pin. When the object is pinged by a program, it pops up a dialog formatted as specified.

The Text Input, Integer Input, and Real Input dialogs are controlled by objects with some general similarities to the Message box:


   +-----------------------------------------------------+
   |                   Text Input                        |
   +--------------------------------------------+--------+
   | Prompt/Label     [ Enter Text:           ] | Value  |
   | Default Value    [                       ] |        |
   | Value Constraint [ strLen(value) > 0     ] | Cancel |
   | Error Message    [ You must enter text.  ] |        |
   +--------------------------------------------+--------+

   +------------------------------------------------------------------------+
   |                           Integer Input                                |
   +---------------------------------------------------------------+--------+
   | Prompt/Label     [ Enter Integer Value:                     ] | Value  |
   | Default Value    [ 5                                        ] |        |
   | Value Constraint [ 0 <= value AND value <= 10               ] | Cancel |
   | Error Message    [ You must an integer between 0 and 10.    ] |        |
   +---------------------------------------------------------------+--------+

   +------------------------------------------------------------------------+
   |                              Real Input                                |
   +---------------------------------------------------------------+--------+
   | Prompt/Label     [ Enter Real Value:                        ] | Value  |
   | Default Value    [ 5                                        ] |        |
   | Value Constraint [ 0 <= value AND value <= 10               ] | Cancel |
   | Error Message    [ You must a real number between 0 and 10. ] |        |
   +---------------------------------------------------------------+--------+
 
They're a little simpler to configure. You can specify a prompt, a default value, a value constraint, and an error message (all these values are programmable). They return a value unless the user cancels the dialog or it times out. The "Edit Properties" object tab folder allows you to specify a timeout, change the button labels (the default values are "OK" and "Cancel"), and specify "password masking", which prevents the input from being displayed as it is typed in.

The List Box object allows you to pop up a dialog with a list:


   +----------------------------------------+
   |               List Box                 | 
   +-------------------------------+--------+
   | List Entries       [ Item 1 ] |  Text  |
   | Default Entry      [ Item 1 ] | Index  |
   |                               | Cancel |
   | [ ] Allow Multiple Selections |        |
   +-------------------------------+--------+
 
The input fields allow you to specify the list, the default entry from the list, and whether to allow multiple selections from the list. The output consists of the text and array index of the selection (if multiselection has been set, these are both arrays) or a cancel output. You can specify the list array and the index of the default selection as inputs. The "Edit Properties" tab folder allows you to select the number of items to be displayed before the list requires scrolling, a timeout, and custom button labels.

Finally, the File Name Selection box allows you to give the user a standard file browser and get a file name back:


   +---------------------------------------------------------+
   |                  File Name Selection                    |
   +---------------------------------------------+-----------+
   | Prompt/Label           [ Enter File Name: ] | File Name |
   | Initial Directory      [ VEE_USER         ] |           |
   | Initial File/Wildcard  [ *.*              ] |   Cancel  |
   | Select File For:       [      Reading     ] |           |
   +---------------------------------------------+-----------+
 
You can specify a prompt, the initial directory, a wildcard pattern, and select for reading or writing; all these features are programmable. The dialog returns a filename or generates a cancel output.

If you want to play with dialogues, check the example programs xgendlg.vee and xmsgdlg.vee.

 TOP OF PAGE

[5.4] ELEMENTARY OUTPUT OBJECTS

* As you should also know by now, VEE has two simple output objects, the Alphanumeric and Scrolling Alphanumeric objects, to allow elementary display of data. A Label object was added in VEE 3.X. All this does is present a string of text, but when placed on the VEE panel view it merges into the panel seamlessly, allowing the text to be "integrated" into the user interface.

VEE also has a nice set of indicator objects. VEE versions before 3.X had a single indicator object, the Meter. VEE 3.X provided minor enhancements for this object, such as choice between horizontal or vertical orientation, with the options set by the following dialog box:


   +----------------------------------------------------------------+
   |                        Meter Properties                        |
   +----------------+---------------+---------------+---------------+
   |     General    |    Colors     |     Fonts     |     Icon      |
   |                +---------------+---------------+---------------+
   |  Title: [ Meter                     ]                          |
   | +- Open View ---------+ +- Debug ----------------+             |
   | | [x] Show Title Bar  | | [ ] Breakpoint Enabled |             |
   | | [ ] Show Terminals  | |                        |             |
   | +---------------------+ +------------------------+             |
   | +- Initialization ----+ +- Layout ---------------------------+ |
   | | [x] Clr at PreRun   | | <*> Horizontal [x] Digital Display | |
   | | [x] Clr at Activate | | < > Vertical                       | |
   | +---------------------+ +------------------------------------+ |
   | +- Sub-Range Configuration ----------------------------------+ |
   | | Enable                                       Min     Max   | |
   | | [x]  [RRRR] Warning Red                    [-1   ] [-1   ] | |
   | | [x]  [YYYY] Yellow                         [-0.8 ] [0.8  ] | |
   | | [x]  [GGGG] Green                          [-0.5 ] [0.5  ] | |
   | +------------------------------------------------------------+ |
   +----------------------------------------------------------------+
   |                [   OK   ] [ Cancel ] [  Help  ]                |
   +----------------------------------------------------------------+
 
You not only can set the orientation (and turn off the digital display if you want it to update faster) but you can also select the colors for each of the ranges. Click on the defined color on the dialog and you get a dialog to allow you to select the color. You can programmatically set the Min or Max values of the Meter object. The other attributes are not programmable.

VEE 3.X added four more indicators: FillBar, Thermometer, Tank, and ColorAlarm.

The FillBar is a simple bar indicator that can be set to provide different colors for three ranges. The Thermometer is just a FillBar with a bulb on the bottom, and the Tank is a fat FillBar. All of them use the same configuration dialog to set their properties, which is similar to that for the Meter:


   +----------------------------------------------------------------+
   |                       FillBar Properties                       |
   +----------------+---------------+---------------+---------------+
   |     General    |    Colors     |     Fonts     |     Icon      |
   |                +---------------+---------------+---------------+
   |  Title: [ Fill Bar                  ]                          |
   | +- Open View ---------+ +- Debug ----------------+             |
   | | [x] Show Title Bar  | | [ ] Breakpoint Enabled |             |
   | | [ ] Show Terminals  | |                        |             |
   | +---------------------+ +------------------------+             |
   | +- Initialization ----+ +- Layout ---------------------------+ |
   | | [x] Clr at PreRun   | | <*> Horizontal [x] Digital Display | |
   | | [x] Clr at Activate | | < > Vertical                       | |
   | +---------------------+ +------------------------------------+ |
   | +- Limits ---------------------------------------+             |
   | | High Color:  [RRRR]  Warning Red               |             |
   | | High Limit:  [ 66     ]                        |             |
   | | Mid Color:   [YYYY]  Yellow                    |             |
   | | Low Limit:   [ 33     ]                        |             |
   | | Low Color:   [GGGG]  Green                     |             |
   | +------------------------------------------------+             |
   +----------------------------------------------------------------+
   |                [   OK   ] [ Cancel ] [  Help  ]                |
   +----------------------------------------------------------------+
 
The major difference is that the range bounds on these three objects are single-ended, while for the Meter there are bounds on both the negative and positive extents of each range. You can set the Min and Max values as well as the High and Low limits programmatically. The other attributes are not programmable.

The ColorAlarm provides essentially an "LED indicator" that changes color (and optionally provides a different text prompt) when the input value crosses into a particular range. It can have a circular or square appearance. The configuration dialog is similar to that of the FillBar except that it allows setting text values for each range and provides different layout options:


   +----------------------------------------------------------------+
   |                      ColorAlarm Properties                     |
   +----------------+---------------+---------------+---------------+
   |     General    |    Colors     |     Fonts     |     Icon      |
   |                +---------------+---------------+---------------+
   |  Title: [ C.A.                      ]                          |
   | +- Open View ---------+ +- Debug ----------------+             |
   | | [x] Show Title Bar  | | [ ] Breakpoint Enabled |             |
   | | [ ] Show Terminals  | |                        |             |
   | +---------------------+ +------------------------+             |
   | +- Initialization ----+ +- Layout ---------------------------+ |
   | | [x] Clr at PreRun   | | < > Rectangle  [x] 3-D Border      | |
   | | [x] Clr at Activate | | <*> Circle     [ ] Digital Display | |
   | +---------------------+ +------------------------------------+ |
   | +- Limits ---------------------------------------------------+ |
   | | High Text:   [ High   ]   High Color:  [RRRR]  Warning Red | |
   | | High Limit:  [ 66     ]                                    | |
   | | Mid Text:    [Mid     ]   Mid Color:   [YYYY]  Yellow      | |
   | | Low Limit:   [ 33     ]                                    | |
   | | Low Text:    [Low     ]   Low Color:   [GGGG]  Green       | |
   | +------------------------------------------------------------+ |
   +----------------------------------------------------------------+
   |                [   OK   ] [ Cancel ] [  Help  ]                |
   +----------------------------------------------------------------+
 
You can programmatically set the High, Mid, and Low limits and text on the Color Alarm object. The other attributes are not programmable. To examine these objects, check the example program xknbinc.vee.

* Two other elementary display objects, the Label and Picture objects, were also introduced in VEE 3.X.

The Label object is much like a Text Constant object. It allows you to display a string of text. The distinction is that when you merge a Label object to your Panel View, it doesn't show a border, the text appears as part of the Panel View.

The Picture object allows a program to load bitmaps at run-time, as well as stretch, size, and tile them. There's not much to it. All the properties are set by the Picture object tab folder:


   +----------------------------------------------------------------+
   |                       Picture Properties                       |
   +----------------+---------------+---------------+---------------+
   |     General    |    Colors     |     Fonts     |     Icon      |
   |                +---------------+---------------+---------------+
   |  Title: [ Picture                   ]                          |
   | +- Open View ---------+ +- Debug ----------------+             |
   | | [x] Show Title Bar  | | [ ] Breakpoint Enabled |             |
   | | [ ] Show Terminals  | |                        |             |
   | +---------------------+ +------------------------+             |
   | +- Picture --------------------------+ +- Preview -----------+ |
   | |[(None)                            ]| |                     | |
   | +----------------+  +-------------+  | |                     | |
   | | (None)         |  |  Browse...  |  | |                     | |
   | | arrow.gif      |  +-------------+  | |                     | |
   | | basic.icn      |   <*> Actual      | |                     | |
   | | beep.icn       |   < > Centered    | |                     | |
   | | blank.gif      |   < > Scaled      | |                     | |
   | | build.icn      |   < > Tiled       | |                     | |
   | | bust.gif       |                   | |                     | |
   | +----------------+-------------------+ +---------------------+ |
   +----------------------------------------------------------------+
   |                [   OK   ] [ Cancel ] [  Help  ]                |
   +----------------------------------------------------------------+
 
You can bring out pins to clear the Picture object or load a new bitmap. GIF, X11 icon, and Windows BMP files are supported.

However, please be warned that 24-bit bitmaps won't work, so you will need to convert 24-bit bitmaps to 8-bit (256 color). You can do this with Windows Paintbrush and its Save As menu selection.

 TOP OF PAGE

[5.5] VEE GRAPH OBJECTS

* VEE includes wide variety of graphical displays: XY Trace, X versus Y Plot, Strip Chart, Waveform, Spectrum -- in Magnitude Spectrum, Phase Spectrum, Polar, or Smith formats -- Polar Plot, or Complex Plane. These objects are simple to use, as long as you provide the proper data to them, but they have a large number of options and can be tricky to deal with.

For example, most allow you to set Log or Linear scales. This sometimes leads to odd results, such as being able to display a graph, but not being able to print it to a printer properly!

Sometimes these are the results of outright printer bugs (and we must admit there were a few VEE printing bugs in the past). But one very common problem is failures to print data on log or semilog scales, due to trying to display data that includes X or Y components with a value of zero.

This is a problem because the log of zero is negative infinity. Try to take log 0 on a calculator and it will give you an error message. VEE tries to be friendly about it and substitute a specific negative limit value -- "machine negative infinity" -- but printer drivers may still not like having a value so far out of range. It is best to not try to display values of zero on log scales.

 TOP OF PAGE

[5.6] USING SHOWPANEL() & HIDEPANEL() / NONMODAL DIALOGS

* VEE 3.X introduced four functions to control the appearance and disappearance of a UserFunction pop-up panel:


   showPanel( UFname )
   showPanel( UFname, x, y )
   showPanel( UFname, x, y, width, height )
   hidePanel( UFname )
 
(UserFunctions are described in detail in later chapters.) These functions allow displays to be created "dynamically" instead of having to rely on a fixed VEE user interface.

The game programs that are shipped with VEE 3.X illustrate some of the interesting things that can be done with dynamic displays, but are rather complicated to explain here. As a simpler example, consider the use of these functions to build a "nonmodal" popup.

The Dialog boxes introduced in VEE 3.X have proven popular, but some people are upset that they are strictly "modal". That is, when the program pops one up, everything stops running until the user makes it go away or it times out. Some people need to be able to display a pop-up while the program is doing something (to tell the user to wait, for instance) and the standard dialogs can't do that.

You can do this with "showPanel()" and "hidePanel()', however. To show how this is done, I created a User Function named "PopUp" that consisted solely of a Label object containing the text "Please Wait ... " in nice big black letters, glued to the Panel View of the User Function. Then I wrote the following program (check out xshopnl.vee for the source):


   +----------------------+
   | showPanel( "PopUp" ) |
   +-----------+----------+     +---------------+
               |                | AlphaNumeric  |
   +-----------+----------+     +---------------+
   | For Count [ 5 0 -1 ] +---->|               |
   +-----------+----------+     +-------+-------+
               |                        |
   +-----------+----------+       +-----+-----+
   | hidePanel( "PopUp" ) |       | Delay (1) |
   +----------------------+       +-----------+
 
I put the Start button and the AlphaNumeric display on the Panel View; when I hit Start, the popup came up and told me to "Please Wait ... " while the count went down to 0, and then obediently vanished.

Note how you can provide optional parameters to "showPanel()" to specify the placement (and size) of the pop-up. It comes up centered if they are not specified.

* A few additional functions to support popups were added in VEE 3.2:

 TOP OF PAGE

[5.7] SHOWPANEL() & HIDEPANEL EXAMPLES

* The showpanel() and hidepanel() functions can be used in interesting ways, as the following three examples demonstrate.

* A customer had an additional requirement for a nonmodal dialog box that could accept inputs. This was a somewhat more complicated requirement. To get input from a nonmodal dialog, you have to do the following things:

If this is as clear as mud, consider an example: A VEE program that is continually updating a clock, but allows you to pop up a dialog to input a name. Pressing OK on the dialog allows the name to be displayed, pressing Cancel just continues with the program.

The guts of the UserFunction are idiot-simple (as noted above, they have to be), consisting of a Text Constant and two Toggle (not OK) buttons:


   +----------------------------------------------------------+
   |                UserFunction: PopUpTest                   |
   +--+----------------------------------------------+--------+
   |  |                                              |        |
   |  |            +--------------------+            |        |
   |  |            | What Is Your Name? |            |        |
   |  |            +--------------------+            |        |
   |  |            |                    +----------->| Name   |
   |  |            +--------------------+            |        |
   |  |                                              |        |
   |  |                                              |        |
   |  |   +--------------+-------------------------->| OK     |
   |  |   |  +--------+  |       +--------+          |        |
   |  |   +->|   OK   +--+    +->| Cancel +--+       |        |
   |  |      +--------+       |  +--------+  |       |        |
   |  |                       +--------------+------>| Cancel |
   |  |                                              |        |
   +--+----------------------------------------------+--------+
 
Note how the Toggles are wired back to their Reset pins. This ensures that they are reset after being toggled by the user. Also remember that you should not set "Wait for Input" on the Text Constant.

I named the UserFunction "PopUpTest". I set up the Panel View like this:


   +-------------------------------------------+
   |                                           |
   |          +--------------------+           |
   |          | What Is Your Name? |           |
   |          +--------------------+           |
   |          |                    |           |
   |          +--------------------+           |
   |                                           |
   |      +--------+          +--------+       |
   |      |   OK   |          | Cancel |       |
   |      +--------+          +--------+       |
   |                                           |
   +-------------------------------------------+
 
The demo program itself is as follows (the source is in the file xpoptest.vee):

   +-------+
   | Until |                                 OK Button
   | Break +--+                              +-------+
   +-------+  |        +---------------+     | Quit  +-----+
              |        | AlphaNumeric  |     +-------+     |
          +---+---+    +---------------+               +---+---+
          | now() +--->|   11:49:54    |               | STOP  |
          +---+---+    +---------------+               +-------+
              |                         
	      |            +-----------------+
              | Toggle     |  If/Then/Else   |
        +-----+-----+      +---+------+------+
     +->| Run Test  +--+-->| A | A==1 | Then +--+
     |  +-----+-----+  |   +---+------+------+  |
     |        |        |                        |
     +--------|--------+           +------------+-----------+
              |                    | showPanel("PopUpTest") |
              |                    +------------------------+
	      |
              |                                   +-------------+
              |                                   |             |
  +-----------+----------+                        |    +--------+-------+
  |     Call Function    |                        |    |  AlphaNumeric  |
  +-------------+--------+                        |    +----------------+
  |             | Name   +------------------------|--->| Wile E. Coyote |
  |[ PopUpTest ]| OK     +-----+                  |    +----------------+
  |             | Cancel +--+  |                  |
  +-------------+--------+  |  |                  |
                            |  |                  |
         +------------------+  |                  |
         |  +------------------+                  |
         |  |                                     |
         |  |   +------------------------------+  |
         |  |   |         If/Then/Else         |  |
         |  |   +--------+-----------+---------+  |   +-----+
         |  +-->| OK     |[OK==1    ]| Then    +--+-->| JCT +--+
         +----->| Cancel |[Cancel==1]| Else If +----->|     |  |
                |        | Else      | Else    |      +-----+  |
                +--------+-----------+---------+               | 
                                                  +------------+-----------+
                                                  | hidePanel("PopUpTest") |
                                                  +------------------------+
 
This program is in the form of a typical "parallel branch" VEE program, in which one branch updates a clock (using "now()" and an AlphaNumeric set to TimeStamp mode), the next allows you to display the UserFunction with "showPanel()", the third tests the panel for inputs, and the fourth (in the upper right corner) allows you to quit.

It is the third branch that is of real interest. It strobes the UserFunction and returns the current state of its inputs; the "OK" and "Cancel" Toggles are tested by an If/Then/Else object to see if either are 1 (meaning the user has toggled them). If "OK" is set to 1, the "Then" output strobes the AlphaNumeric to display the current "Name" string. If either are set, the UserFunction is hidden with "hidePanel()".

Variations can be constructed on this theme as long as the basic rules are followed: you just have to strobe the UserFunction on a regular basis and it cannot contain any objects that might cause it to hang.

* A VEE user wanted to be able to display data from several VEE functions successively in a single VEE pop-up panel. As it turns out, this is very easy to do.

The following example program contains three UserFunctions to perform elementary math operations, named "RootFn()", "SquareFn()", and "LogFn()". It also includes a UserFunction named "DispFn()" that generates a panel to display the output of the math operations.


   +------+      +-------------+   +--------------------------+
   | Real |      |   Formula   |   |         Formula          |
   +------+      +-------------+   +--------------------------+
   | 2    +--+-->|  RootFn(A)  +-->| DispFn(A, "Square Root") |
   +------+  |   +-------------+   +------------+-------------+
             |                                  |
	     |                       +----------+-----------+
	     |                       | ShowPanel("DispFn")  |
	     |                       +----------+-----------+
	     |                                  |
             |                            +-----+-----+
             |                            | Delay:  2 |
             |                            +-----+-----+
             |                                  |
             |   +-------------+   +------------+-------------+
             |   |   Formula   |   |         Formula          |
             |   +-------------+   +--------------------------+
             +-->| SquareFn(A) +-->| DispFn(A, "Square Root") |
             |   +-------------+   +------------+-------------+
             |                                  |
             |                            +-----+-----+
             |                            | Delay:  2 |
             |                            +-----+-----+
             |                                  |
             |   +-------------+   +------------+-------------+
             |   |   Formula   |   |         Formula          |
             |   +-------------+   +--------------------------+
             +-->|  RootFn(A)  +-->| DispFn(A, "Square Root") |
                 +-------------+   +------------+-------------+
                                                |
                                          +-----+-----+
                                          | Delay:  2 |
                                          +-----------+
 
There's nothing to the math UserFunctions -- each just contains a simple Formula box with the proper math function -- and the "DispFn()" UserFunction is very simple as well, consisting only of two AlphaNumerics:

   +---------------------------------------+
   |                DispFn                 |
   +---------+-----------------------------+
   |         |                             |
   |         |    +----------------------+ |
   |         |    |     AlphaNumeric     | |
   |         |    +----------------------+ |
   | FnData  +--->|                      | |
   |         |    +----------------------+ |
   |         |                             |
   |         |    +----------------------+ |
   |         |    |     AlphaNumeric     | |
   |         |    +----------------------+ |
   | FnLabel +--->|                      | |
   |         |    +----------------------+ |
   |         |                             |
   +---------+-----------------------------+
 
The AlphaNumerics are placed on a simple panel display as follows:

   +--------------------------+
   |          DispFn          |
   +--------------------------+
   |                          |
   | +----------------------+ |
   | |        FNData        | |
   | +----------------------+ |
   | |                      | |
   | +----------------------+ |
   |                          |
   | +----------------------+ |
   | |        FNLabel       | |
   | +----------------------+ |
   | |                      | |
   | +----------------------+ |
   |                          |
   +--------------------------+
 
It is not necessary to set the "Show Panel On Execute" property for this UserFunction.

In practice, the "DispFn()" panel is initialized to the square root value and then displayed by "ShowPanel()". It is then updated sucessively to the other values every two seconds. Nothing to it.

Source is available as xpopdisp.vee.

* A VEE user wanted to create a pop-up UserFunction in VEE that would have a timeout: if the user did not hit a button input within a certain interval, the pop-up would go away.

If the user did hit a button input within that interval, the pop-up would remain visible indefinitely, and then go away.

This can be implemented with the following UserFunction, named PopDelay():


   +-----------------------------------------------------------------------+
   |                        UserFunction PopDelay                          |
   +-----------------------------------------------------------------------+
   |                                                                       |
   |  +-------+   +-----------------+                                      |
   |  | now() +-->| Set Global:  T0 | Get time zero for delay calculation. |
   |  +-------+   +--------+--------+                                      |
   |                       |                                               |
   |  +-------+   +--------+--------+                                      |
   |  | 0     +-->| Set Global:  PF | Clear flag to indicate toggle set.   |
   |  +-------+   +--------+--------+                                      |
   |                       |                                               |
   |                   +---+---+                                           |
   |                   | Until |                                           |
   |                   | Break +--+                                        |
   |                   +-------+  |                                        |
   |                              |                                        |
   |                         +----+----+                                   |
   |               reset +-->| Button  +---+ toggle control                |
   |                     |   +---------+   |                               |
   |  +------------------+-----------------+                               |
   |  |                                                                    |
   |  |   +------------------------------------------+                     |
   |  |   |               If/Then/Else               |                     |
   |  |   +---+----------------------------+---------+                     |
   |  |   |   | (PF==0) AND (now()-T0 > 5) | Then    +----------+          |
   |  +-->| A | (PF==0) AND (A==1)         | Else If +------+   |          |
   |      |   | (PF==1) AND (A==1)         | Else If +--+   |   |          |
   |      +---+----------------------------+---------+  |   |   |          |
   |                                                    |   |   |          |
   |           +----------------------------------------+   |   |          |
   |           |                             +--------------+   |          |
   |           |                             |                  |          |
   |    +------+------+   +-----+   +--------+--------+  +------+------+   |
   |    |     Exit    |   | 1   +-->| Set Global: PF  |  |    Exit     |   |
   |    | UserObject  |   +-----+   +-----------------+  | UserObject  |   |
   |    +-------------+                                  +-------------+   |
   |                                                                       |
   +-----------------------------------------------------------------------+
 
The important features of this UserFunction are as follows:

Source for this example is available as xpopdel.vee.

 TOP OF PAGE


 LAST PAGE  BACK TO INDEX  NEXT PAGE