Partager via


NORMALIZE( ) Function

Converts an expression, supplied by a user, into the same form of the expression used internally by Visual FoxPro. You can use the normalized form of an expression to make more accurate comparisons with the expressions returned from Visual FoxPro commands or functions.

NORMALIZE(cExpression)

Return Value

Character

Parameters

  • cExpression
    Specifies the character expression to normalize.

Remarks

NORMALIZE( ) returns a character string from the character expression cExpression with the following changes. NORMALIZE( ):

  • Converts the character expression to uppercase. However, it does not change embedded strings. An example of an embedded string is "Hello" in the character expression "LEFT('Hello',1)".

  • Expands any abbreviated Visual FoxPro keywords in the character expression to their full length.

  • Converts to periods any -> operators that separate aliases from field names.

  • Surrounds by periods the logical operators AND, OR and NOT: .AND. .OR. .NOT.

  • In filter expressions, removes any blank spaces between terms.

  • Checks the syntax of any Visual FoxPro commands or functions within the character expression, However, it does not evaluate the expression. If the syntax is incorrect, Visual FoxPro generates a syntax error. NORMALIZE( ) does not look for any fields, tables, memory variables, user-defined functions, or other references in the character expression.

For example, a user may enter an index expression such as the following in the Expression Builder:

UPPE(cust->lname) + UPPE(cust->fname)

While this is a valid Visual FoxPro index key expression, it is difficult to compare this to the return values from a Visual FoxPro function like KEY( ). NORMALIZE( ) returns the following character string for the expression above:

UPPER(CUST.LNAME) + UPPER(CUST.FNAME)

You can easily compare this to the value returned by a function like KEY( ). This enables you to verify the existence of an index or index tag with the user-supplied index expression.

Also, you can use NORMALIZE to compare the results of SET("Filter") or FILTER( ). For example, you could create the following filter expression:

STORE '"VIRGINIA" $ UPPER(state) AND NOT "MAINE" $ UPPER(state)' TO
MyFilter
USE Addresses
 LINK Word.Document.8 "C:\\Documents and Settings\\v-rodhil\\My Documents\\DocStudio\\Projects\\dv_foxhelp91\\cc1ce3c4-1dc6-4d8f-9406-c8bab4d6a40a.xml" "OLE_LINK1" \a \r  \* MERGEFORMAT STORE '"VIRGINIA" $ UPPER(state) AND NOT "MAINE" $ UPPER(state)' TO
MyFilter
SET FILTER TO &MyFilter

However, the value returned by SET("Filter") or FILTER( ) will not exactly match the original filter.

? SET("FILTER") == MyFilter  && .F.

SET("FILTER") or FILTER( ) return the following:

"VIRGINIA"$UPPER(STATE).AND..NOT."MAINE"$UPPER(STATE)

To ensure a correct comparison, use:

? NORMALIZE(MyFilter) == SET("FILTER")  && .T."

See Also

Reference

EVALUATE( ) Function

ISUPPER( ) Function

PROPER( ) Function

UPPER( ) Function

Other Resources

Functions