PROMPT
From CometWiki
PROMPT Syntax: The PROMPT statement has several variations: PROMPT %PromptName% length prompt-string [default value] PROMPT %PromptName% length prompt-string [ENTER program,dir,"message"] PROMPT %PromptName% ENTER program,dir,"message" PROMPT CAPTION caption-string
Placement: The PROMPT statements need to be defined before their use as a replacement string. It is recommended that they be located at the top of the report spec.
Discussion: The PROMPT statement is used to prompt the operator at runtime for a value to be used to replace text in a Reporter command. For example, the operator can be prompted for a printer name, a range of dates, or the text for a TITLE statement.
One PROMPT statement is used for each value to be replaced. It is best to group all PROMPT statements for the report together. At runtime the Reporter collects the PROMPT statements and creates a dialog to prompt the operator for each of the replacement strings in the group. When a default value is specifed in the PROMPT the dialog is populated with that value.
The ENTER option expands the possibilities for prompting the operator for replacement strings. ENTER programs can popup date pickers, customer lists, etc. To assist you with two of the most popular uses of this statement Signature Systems has provided the source for a date picker (datepick.ibs) and printer picker (ptrpick.ibs)in the XTL folder.
Examples: PROMPT CAPTION Invoices for Specified Date Range
PROMPT %startdate% 8 From date: [ENTER datepick,,"YY/MM/DD,Enter from date"]
PROMPT %enddate% 8 To date: [ENTER datepick,,"YY/MM/DD,Enter to date"]
PROMPT %printer% 3 Printer name: [ENTER ptrpick]
PRINTER %printer%
TITLE Invoice from %startdate% thru %enddate%
INPUT invoice.header
REPORT
SELECTING inv.date ge %startdate% and inv.date le %enddate%
PRINT ivh.no;cust.no;inv.total
When the report runs, the Reporter pops up this dialog:
Notice the caption string at the top of the dialog. This came from the statement
PROMPT CAPTION Invoices for Specified Date Range
Each of the prompts in this example is associated with an ENTER program invoked when the control for the prompt gets the focus. When the operator clicks on the "From Date:" field, the Reporter ENTERs the datepick subprogram:
The caption on the date picker comes from the PROMPT statement:
PROMPT %startdate% 8 From date: [ENTER datepick,,"YY/MM/DD,Enter from date"]
The other parameter passed to datepick is the format specifying that the date will be returned in (YY/MM/DD) format.
When the printer prompt gets the focus, the ptrpick program is ENTERed:
After the operator clicks "OK" on the main dialog, the Reporter runs the report. For each statement it reads it scans the text looking for a %PromptName% and substitutes the associated text.
The silent ENTER option provides a way to run a program without operator interface to provide the string substitution:
PROMPT %PromptName% ENTER program,dir,"message"
In this case a field for this substitution will not be included in the dynamically created dialog. The program will be ENTERed and its value saved for substitution later in the report. This can be useful for getting operator or other context-sensitive information that your application knows without having to ask the operator.
Of course the datepick and ptrpick programs may be customized to your needs. You will find the source in the XTL folder.