17. Forms Statements : prompt Statement—Prompt the User for Input
 
Share this page                  
prompt Statement—Prompt the User for Input
This statement prompts the user for input.
Syntax
prompt [noecho] (string, string_var)
    [with style=menuline |
    popup [(option=value {, option=value})]]
Description
The prompt statement displays a prompt on the screen and accepts user input. String, which contains the text of the prompt, must be a quoted string literal or a program variable. String_var is a string variable to hold the user's response to the prompt. A maximum of 200 characters are returned; if the screen width is less than 200 characters, then the maximum number of characters returned corresponds to the screen width. If the user fails to respond to the prompt, and a timeout period is specified in the application, then a zero-length string is returned in string_var when timeout occurs.
If you omit the style clause or specify style = menuline, the prompt appears on the last line of the screen. In such cases, the maximum allowable length of the prompt is equal to the width of the screen. The user's response occupies an entire line for pop-up style prompts (unless you specify noecho).
When you specify the pop-up style, the prompt appears inside a pop-up box. Using the pop-up style allows you to display a multi-line prompt.
The options specify the location and size of the pop-up. Valid options are:
startcolumn
Specifies the column position of the upper left hand corner of the pop-up
startrow
Specifies the row position of the upper left hand corner of the pop-up
columns
Specifies the number of columns, including borders, that the pop-up occupies
rows
Specifies the number of rows, including borthat the pop-up occupies
An option value can be an integer literal, an integer variable, or the word default. Default values are the FRS default values:
startcolumn—The second column
startrow—Determined by the size of the string
columns—The width of the screen minus 2
rows—The number of rows needed to display the prompt, plus one row for your response. This value never exceeds the number of rows on the screen minus one row for the menu line.
The integer equivalent of the keyword default is 0.
The starting location, defined by startcolumn and startrow, cannot be less than 1,1. This pair of coordinates, located in the upper left hand corner of the screen, describes the origin point on the screen. Column and row values increase as you move to the right and down the screen, respectively.
If the starting location is defaulted, FRS selects a location that displays the prompt just above the menu line.
The columns and rows options determine the size of the pop-up box. The size cannot be smaller than 16 columns by 4 rows and must allow room for the border. If the box size and starting location, in combination, force the box to be wholly or partially off the screen, FRS attempts to adjust the starting location so that the entire box can be displayed. The prompt is not displayed unless the entire box is on the screen.
If the key word noecho is specified, the user's input is not displayed on the screen. Noecho is useful in situations where a password is required.
Examples—prompt statement:
Example 1:
Prompt the user for an employee's department.
exec frs prompt ('Enter the department: ', :deptvar);
Example 2:
Prompt for a password before opening a database cursor to view employee information.
exec frs prompt noecho ('Enter Password: ', :passwd);
 if (passwd = 'leviticus') then
    exec sql open viewemp;
else
    exec frs message 'No permission for task';
    exec frs sleep 2;
end if;
Example 3:
Use a prompt as an interactive message displayed at the top of the screen.
exec frs prompt ('An error has occurred 
    [Press Return]', :var) 
    with style=popup (startcolumn=1, startrow=1);