Displays theso you can create an expression and store the expression to a variable or array element.
GETEXPR [cCaptionText] TO MemVarName [TYPE cExpressionType [; cErrorMessageText]] [DEFAULT cDefaultExpression]
Specifies the caption that appears in the Expression Builder. The caption can be used to remind the user of what kind of expression to build.
- TO MemVarName
Specifies the variable or array element in which the expression is stored. If the variable doesn't already exist, Visual FoxPro creates it. GETEXPR won't create an array element.
If you exit the Expression Builder by pressing ESC or by choosing Cancel, the empty string is stored to the variable or array element. If a default expression is created with the DEFAULT clause, the default expression is stored to the variable if you exit the Expression Builder by pressing ESC or choosing Cancel.
- TYPE cExpressionType [; cErrorMessageText]
Specifies the expression type. The following table lists the character to specify in cExpressionType for each expression type:
cExpressionType Expression type
You can specify the error message cErrorMessageText to be displayed if the expression isn't valid. If cErrorMessageText is included with cExpressionType, cExpressionType and cErrorMessageText must be separated by a semicolon (;). The combination of cExpressionType, the semicolon, and cErrorMessageText must be enclosed in single or double quotes in matching pairs.
- DEFAULT cDefaultExpression
Makes it possible for you to display the initial default expression in the Expression Builder. You can accept the default expression or overwrite it with your own expression specified with cDefaultExpression. cDefaultExpression is stored to the variable or array element if you exit the Expression Builder by pressing ESC or choosing Cancel.
In the following example, GETEXPR is used to get a LOCATE expression of the proper type. If LOCATE is successful, the company name is displayed; otherwise, a message is displayed.
CLOSE DATABASES OPEN DATABASE (HOME(2) + 'Data\testdata') USE customer && Opens Customer table GETEXPR 'Enter condition to locate ' TO gcTemp; TYPE 'L' DEFAULT 'COMPANY = ""' LOCATE FOR &gcTemp IF FOUND( ) DISPLAY ELSE ? 'Condition ' + gcTemp + ' was not found ' ENDIF