The LET Command

How to:

The LET command enables you to represent a word or phrase with another word. This reduces the amount of typing necessary for issuing requests, and makes the requests easier to understand. A substitution is especially useful when you use the same phrase repeatedly. Note that you cannot use LET substitutions in Dialogue Manager commands, and substitutions cannot be used in a MODIFY or Maintain request.

The LET command has a short form and a long form. Use the short form for one or two LET definitions that fit on one line. Otherwise, use the long form.

When you define a word with LET then use that word in a request, the word is translated into the word or phrase it represents. The result is the same as if you entered the original word or phrase directly. You can substitute any phrase that you enter online unless you are entering a MODIFY request.

A LET substitution lasts until it is cleared or until the request terminates. To clear active LET substitutions, issue the LET CLEAR command. To use the same substitutions in many requests, place the LET commands in a stored procedure. If you want to save currently active LET substitutions, use the LET SAVE facility. These substitutions can then be executed later with one short command.

Syntax: How to Make a Substitution (Short Form)

LET word = phrase [;word = phrase...]

where:

word

Is a string of up to 80 characters with no embedded blanks.

phrase

Is a string of up to 256 characters, which can include embedded blanks. The phrase can also include other special characters, but semicolons and pound signs need special consideration. If the word you are defining appears in the phrase you are replacing, you must enclose it in single quotation marks.

More than one substitution can be defined on the same line by placing a semicolon between definitions.

Example: Making a Substitution (Short Form)

The LET command defines the word WORKREPORT as a substitute for the phrase TABLE FILE EMPLOYEE:

LET WORKREPORT = TABLE FILE EMPLOYEE

Issuing the following

WORKREPORT
PRINT LAST_NAME
END

results in this request:

TABLE FILE EMPLOYEE
PRINT LAST_NAME
END

The next command includes TABLE as both the word you are defining and as part of the phrase it is replacing. It is enclosed in single quotation marks in the phrase:

LET TABLE = 'TABLE' FILE EMPLOYEE

More than one word is defined in the following command. The definitions are separated by a semicolon:

LET WORKREPORT=TABLE FILE EMPLOYEE; PR=PRINT

Syntax: How to Make a Substitution (Long Form)

LET 
word = phrase 
.
.
.
END

where:

word

Is a string of up to 80 characters with no embedded blanks.

phrase

Is a string of up to 256 characters, and can include embedded blanks.

END

Is required to terminate the command.

As shown, LET and END must each be on a separate line.

As with the short form, you can define several words on one line by separating the definitions with a semicolon.

Example: Making a Single Substitution (Long Form)

The following example illustrates a single substitution.

LET
RIGHTNAME = 'STEVENS' OR 'SMITH' OR 'JONES' OR 'BANNING' OR 'MCCOY' OR 
'MCKNIGHT'
END

Example: Making Multiple Substitutions (Long Form)

The following example illustrates substitutions that span more than one line. Notice that there is no semicolon after the definition PR = PRINT:

LET
WORKREPORT = TABLE FILE EMPLOYEE; PR = PRINT
RIGHTNAME  = 'STEVENS' OR 'SMITH' OR 'JONES'
END

Example: Defining Substitutions for Translation

Non-English speakers can use LET commands to translate a request into another language. For example, this request

TABLE FILE CAR
SUM AVE.RCOST OVER AVE.DCOST
BY CAR ACROSS COUNTRY
END

can be translated into French as:

CHARGER FICHIER CAR
SOMMER AVE.RCOST SUR AVE.DCOST
PAR CAR TRAVERS COUNTRY
FIN

Information Builders