Summary:
See also: Record Input, Programs, Variables
The PROMPT instruction can be used to query for a single value from the user.
In graphical mode, the PROMPT instruction opens a modal window with an OK button and a Cancel button:
The PROMPT statement can assign a user-supplied value to a variable.
PROMPT question
[ ATTRIBUTE ( question-attributes ) ]
FOR [CHAR[ACTER]] variable
[ HELP number ]
[
ATTRIBUTE ( input-attributes ) ]
[ dialog-control-block
[...]
END PROMPT ]
where dialog-control-block is one of :
{ ON IDLE idle-seconds
statement
[...]
| ON ACTION action-name
statement
[...]
| ON KEY ( key-name [,...]
)
statement
[...]
}
The following table shows the question-attributes supported by the PROMPT statement:
Attribute | Description |
BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, WHITE, YELLOW Console Only! |
The color of the displayed text. |
BOLD, DIM, INVISIBLE, NORMAL Console Only! |
The font attribute of the displayed text. |
REVERSE, BLINK, UNDERLINE Console Only! |
The video attribute of the displayed text. |
The following table shows the display attributes that can be used in input-attributes:
Attribute | Description |
BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, WHITE, YELLOW Console Only! |
The color of the entered text. |
BOLD, DIM, INVISIBLE, NORMAL Console Only! |
The font attribute of the entered text. |
REVERSE, BLINK, UNDERLINE Console Only! |
The video attribute of the entered text. |
The following table shows the control attributes that can be used in input-attributes:
Attribute | Description |
CENTURY = string | Specify a year format indicator as defined in the CENTURY attribute of form files. |
FORMAT = string | Specify a display format as defined in the FORMAT attribute of form files. |
PICTURE = string | Specify an input picture as defined in the PICTURE attribute of form files. |
SHIFT = string | Specify uppercase or lowercase shift. Values can be 'up' or 'down' . |
WITHOUT DEFAULTS [ =bool] | Prompt must show by default the value of the program variable. |
CANCEL = bool | Indicates if the default action 'cancel' should be added to the dialog. If not specified, the action is registered. |
ACCEPT = bool | Indicates if the default action 'accept' should be added to the dialog. If not specified, the action is registered. |
You can use this instruction to manage a single value input.
To use the PROMPT statement, you must do the following:
You can use this instruction to manage a single value input. You provide the text of the question to be displayed to the user and the variable that receives the value entered by the user. The runtime system displays the question in the prompt area (typically a popup window), waits for the user to enter a value, reads whatever value was entered until the user validates (for example with the RETURN key), and stores this value in a response variable. The prompt dialog remains visible until the user enters a response.
The HELP clause specifies the number of a help message to display if the user invokes the help while executing the instruction. The predefined 'help' action is automatically created by the runtime system. You can bind action views to the 'help' action.
When an PROMPT instruction executes, the runtime system creates a set of default actions.
The following table lists the default actions created for this dialog:
Default action | Control Block execution order |
accept | Validates the PROMPT dialog (validates field criterias) Creation can be avoided with the ACCEPT attribute. |
cancel | Cancels the PROMPT dialog (no validation, int_flag is set) Creation can be avoided with the CANCEL attribute. |
close | By default, cancels the PROMPT dialog (no validation, int_flag is set) Default action view is hidden. See Windows closed by the user. |
help | Shows the help topic defined by the HELP clause. Only created when a HELP clause is defined. |
You can use ON ACTION blocks to execute a sequence of instructions when the user raises a specific action. This is the preferred solution compared to ON KEY blocks, because ON ACTION blocks use abstract names to control user interaction.
The ON IDLE idle-seconds clause defines a set of instructions that must be executed after idle-seconds of inactivity. The parameter idle-seconds must be an integer expression. If it evaluates to zero, the timeout is disabled.
For backward compatibility, you can use ON KEY blocks to execute a sequence of instructions when the user presses a specific key. The following key names are accepted by the compiler:
Key Name | Description |
ACCEPT | The validation key. |
INTERRUPT | The interruption key. |
ESC or ESCAPE | The ESC key (not recommended, use ACCEPT instead). |
TAB | The TAB key (not recommended). |
Control-char | A control key where char can be any character except A, D, H, I, J, K, L, M, R, or X. |
F1 through F255 | A function key. |
DELETE | The key used to delete a new row in an array. |
INSERT | The key used to insert a new row in an array. |
HELP | The help key. |
LEFT | The left arrow key. |
RIGHT | The right arrow key. |
DOWN | The down arrow key. |
UP | The up arrow key. |
PREVIOUS or PREVPAGE | The previous page key. |
NEXT or NEXTPAGE | The next page key. |
01
MAIN02
DEFINE birth DATE03
DEFINE chkey CHAR(1)04
PROMPT "Please enter your birthday: " FOR birth05
DISPLAY "Your birthday is : " || birth06
PROMPT "Now press a key... " FOR CHAR chkey07
DISPLAY "You pressed: " || chkey08
END MAIN
01
MAIN02
DEFINE birth DATE03
LET birth = TODAY04
PROMPT "Please enter your birthday: " FOR birth05
ATTRIBUTE(WITHOUT DEFAULTS)06
ON ACTION action107
DISPLAY "Action 1"08
END PROMPT09
DISPLAY "Your birthday is " || birth10
END MAIN