ASK

Syntax

ASK substitution_variable [prompt]

Description

Retrieves values for a compile-time substitution variable. The retrieval can be by user input or command-line arguments, or as entries in the @file on the command line.

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}'. When the substitution variable is text or date, enclose the brackets with single quotes. Substitutions are made when 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 the ASK command across program lines.

Parameters

Parameter Description

Substitution_variable

The variable to be used as the substitution variable.

Prompt

An optional, literal text string to be displayed as a prompt if the value for the substitution variable is not entered on the command line or in an argument file.

Example

In the following example, state takes the value entered by the user 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 The INPUT command for information about input at runtime.