Application: Extend the built-in inputdialog function such that it automatically closes after a user-specified timeout and returns default values.
The built-in inputdialog function can be used to prompt for up to six input values as combo boxes, plain text fields, or check items. It's quite powerful, but it lacks a way to return after a user-specified timeout. Function @TimedInputDialog() in the following script extends inputdialog while retaining a similar call interface.
Interesting techniques:
Start by studying @TimedInputDialog first. It makes heavy use of the event plugin. For each TimedInputDialog it creates two events, e and e1. e is created first to countdown the inputdialog window and handle stop triggers. At this point the inputdialog window doesn't exist yet. Then e1 is created to wait for a new builtin inputdialog window. In order to support concurrent inputdialogs, the inputdialog window caption is set to a unique string. When e1 matches that unique string, it stores the window handle in a global map, sets the caption to a user-specified title and terminates itself, leaving timeout management to event e. Eventually e either self-destroys when the timeout expires, or is destroyed by the script because the user pressed the OK button.
A key idea in this implementation is to store values that are associated with events in a global map named gmTimedInputDialog. This makes it possible to consistenly retrieve return/status values without knowing whether the inputdialog terminated because of a timeout or because the user closed it. The global map is also used to store the inputdialog caption and the window handle. Thus the map is treated as an "array of records". To address a field in the record, a string index is used, for instance "h"+e addresses the "h" field of the e-th record, where e is the unique event handle returned by the event plugin.
Finally, the first part of this script, before @TimedInputDialog, demonstrates how to call @TimedInputDialog. It is interesting in its own right, because it shows how to spawn multiple concurrent TimedInputDialogs by means of events.
For more details you really need to study the code below.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PURPOSE
Demonstrate TimedInputDialog() function, see @TimedInputDialog in this file
CONFIGURATION FOR THIS SCRIPT
Required Plugins and Programs:
- event v.2003.11.31 included in PP3.8.01 package: see .@TimedInputDialog
- map v.2003.02.16: see .@TimedInputDialog
- win: v 2003.01.31 see .@TimedInputDialog
- miscplugin: sleep service
- ppbang.exe: (temporary, until event plugin is fixed)
Set ' as the quote character and & as the expression character in PowerPro config.
Change History:
20031127 v1.0 base version
20031201 v1.1 use event plugin version 2003 11 30
Documentation:
All comments in this file.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|