Click or drag to resize

Normalize Function

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

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION Normalize(
	cExpression
) AS STRING CLIPPER
Request Example View Source

Parameters

cExpression (Optional)
Type: Usual
Specifies the character expression to normalize.

Return Value

Type: String
Character
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 X# 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 X# commands or functions within the character expression, however, it does not evaluate the expression. If the syntax is incorrect, X# 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:
X#
1UPPE(cust->lname) + UPPE(cust->fname)
While this is a valid X# index key expression, it is difficult to compare this to the return values from a X# function like KEY( ). Normalize( ) returns the following character string for the expression above:
X#
1UPPER(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:
X#
1STORE '"VIRGINIA" $ UPPER(state) AND NOT "MAINE" $ UPPER(state)' TO
2MyFilter
3Use Addresses
4LINK Word.Document.8 "C:\\Documents and Settings\\v-rodhil\\My Documents\\DocStudio\\Projects\\dv_foxhelp91\\cc1ce3c4-1dc6-4d8f-9406-c8bab4d6a40a.xml"
5"OLE_LINK1" \a \r  \* MERGEForMAT STORE '"VIRGINIA" $ UPPER(state) AND NOT "MAINE" $ UPPER(state)' TO
6MyFilter
7Set Filter TO &MyFilter
However, the value returned by Set("Filter") or Filter( ) will not exactly match the original filter.
X#
1? Set("Filter") == MyFilter  // .F.
Set("Filter") or Filter( ) return the following:
X#
1"VIRGINIA"$UPPER(STATE).AND..NOT."MAINE"$UPPER(STATE)
To ensure a correct comparison, use:
X#
1? Normalize(MyFilter) == Set("Filter")  // .T."
See Also