ASK

Function

Retrieves values for compile-time substitution variables. Retrieval can be by user input, command-line arguments, or as entries in @file on the command line. (See .Production Reporting Command-line Arguments for more information.)

Syntax

ASK substitution_variable [prompt]

Arguments

substitution_variable

Variable to use as the substitution variable.

prompt

(Optional) Literal text string displayed as a prompt if the substitution variable value is not entered on the command line or in an argument file.

Description

The value of the substitution variable replaces the reference variable in the program. Variables are referenced by enclosing the variable name in braces, for example, '{state_name}'. If the substitution variable is text or date, surround the brackets by single quotes. Substitutions are made as the program is compiled and are saved in the SQT file. Each variable can be referenced multiple times.

ASK is used only in the SETUP section and must appear prior to any substitution variable references.

You cannot break ASK across program lines.

Examples

In the following example, state takes the user-supplied value in response to the prompt Enter state for this report.

begin-setup
  ask state 'Enter state for this report'
end-setup
  ...
begin-select
  name, city, state, zip
  from customers where state = '{state}'
end-select

See Also