You are here: Commands > Accept

Accept

The Accept command allows users to create interactive procedures that pause to display a dialog prompting a user for information.

This command can be issued only in command mode. It cannot be used within a Group command. It is good practice to place all Accept commands at the beginning of a procedure.

Use Accept to create procedures that prompt the user to provide information, such as sampling intervals, file names, department numbers or report headers and footers.

Analyzer stores the user input in a character variable. When the user input is a numeric value needed for a subsequent Analyzer command, the command interprets the user input as a character value. You may need to convert the character data in the variable to numeric or date format before you can use it in other operations.

To use the literal content of a variable in a subsequent command or operation, you can refer to the variable by name. To have Analyzer interpret the content of a variable as a field name or a file name, use the percent character (%) before and after the variable name. This converts the variable name into a macro and tells Analyzer to treat the content of the variable as a reference to a named field or file.

For more information, see Variables, Interactive Procedures and Macro Substitution.

To create more complex dialogs, use the Dialog command. For more information, see Dialog.

Creating Dialog Boxes with the Accept Command

When Analyzer encounters the Accept command, it temporarily suspends the procedure and displays a dialog prompting the user to enter information. Clicking [OK] in the dialog instructs Analyzer to accept the information and resume processing of the procedure. Clicking [Cancel] cancels execution of the procedure.

There are two ways to request input from a user. You can have the user enter text in a text box or make a selection from a drop-down list. Drop-down lists can contain the names of fields, variables or Project items such as procedures, table layouts, indexes, Views and reports. To create a drop-down list, use the optional Fields parameter with one or more of the field-type identifiers. For more information, see Field Type Syntax.

If a table is open when an Accept or Dialog command is issued, drop-down lists will contain only specified items from the currently open table. If no table is open when the command is issued, drop-down lists will be blank.

Parameters

The Accept command has the following command parameters:

Fields

Allows users to use drop-down lists instead of text boxes for user input. Drop-down lists can contain one or more field types.

To

Assigns the user response to a named character variable.

Note: For a description of supported field modifiers see Field Modifiers.

Command Mode Syntax

Each separate Accept command generates a separate dialog. To create a dialog with multiple prompts, use a single Accept command with multiple prompt strings and variable names separated by commas.

ACCEPT "prompt-string" <FIELDS "field types"> TO variable-name <, .... >

• prompt-string specifies the message that prompts the user for information during execution of the procedure. The prompt string must be surrounded by quotes and should be brief.
• variable-name specifies the name of the character variable that stores the user’s response and does not require quotes. If the named variable already has a value, the dialog displays it.
• field types specify the field types to be displayed in the drop-down list. The field types must be surrounded by quotes. Field names and variable names can appear in the same drop-down list. For example, FIELDS "CNLD" generates a drop-down list containing the names of all fields and FIELDS "CNLDcnld" generates a drop-down list containing the names of all fields and all variables.

Note: Do not mix "xixrxbxfxw" items with "CcNnLlDd" items. You should not have Project item types in the same list with field names or variable names. This may result in inappropriate user choices that cause processing errors.

Field Type Syntax

 

Field type

 

Generates a drop-down list containing:

C

Character fields

c

Character variables

N

Numeric fields

n

Numeric variables

L

Logical fields (filters)

l

Logical variables

D

Date fields

d

Date variables

xb

Procedures

xf

Tables

xi

Indexes

xr

Views and reports

xw

Workspaces

 

Single-Prompt Dialog Boxes

To create a single-prompt dialog, use only one prompt string for each instance of the Accept command. Use the following syntax to create a procedure named Random_sample that generates separate prompts for a file name, a drop-down list of fields that can be sampled, a sampling interval and a random start value.

Note: The % character shown in the OPEN command syntax below is used to refer to the contents of the named variable when the variable is used to store a file name or a field name. For more information see Macro Substitution.

ACCEPT "Enter the filename to analyze" TO FILENAME

OPEN %FILENAME%

ACCEPT "Select the field to sample" FIELDS "N" to SAMFIELD

ACCEPT "Enter the sampling interval" TO SAMINT

ACCEPT "Enter the random start value" to RANSTART

SAMPLE ON %SAMFIELD% INTERVAL SAMINT FIXED RANSTART RECORD TO INVSAMP

When you run the procedure, the first dialog prompts you for the file name.

The second dialog prompts you for the name of the field to be sampled. The syntax for this prompt, shown in the third command line above, uses the keyword:

FIELDS 'N'

As a result, this dialog contains a drop-down list of available numeric fields.

The third dialog prompts you for the interval value.

And the fourth dialog prompts you for the random start value.

Analyzer displays the results of the procedure in the Command Log.

Multiple-Prompt Dialog Boxes

To create a multiple-prompt dialog, enter multiple sets of command parameters separated by commas for one instance of the Accept command, all on the same line, as follows:

ACCEPT 'Select the field to sample' FIELDS 'N' TO SAMFIELD, 'Enter the sampling interval' TO SAMINT, 'Enter the random start value' TO RANSTARTΏ

The Accept command above produces a dialog with one drop-down list of field names and two text boxes.