Normalize()
We're hard-pressed to come up with an explanation of how this little gem got added to the language. Its purpose is to validate an expression as legitimate VFP syntax, and it does an okay "first pass" job of it, but testing TYPE() and EVAL() is just as accurate. Nonetheless, this is a cool function that makes it easier to compare user input to information you retrieve using FoxPro functions. NORMALIZE() takes a string and converts it to a standard format like that returned by many of FoxPro's built-in functions. FoxPro keywords get expanded to full length and converted to uppercase, and the "->" turns into a period. Plus, the syntax of the expression is checked.
Usage |
cCleanExpr = NORMALIZE( cExpr ) |
IF X Ywithout an error message. The "Y" was seen as a comment. We wish the developers had made NORMALIZE()'s test more stringent, though.In spite of the error-checking weaknesses, we still think NORMALIZE() is pretty cool. Just don't count on it to find errors in input expressions. Even though it's cool, we can't see a lot of places we're going to actually use NORMALIZE()—let us know if you come up with some.
Example |
? NORMALIZE('upper(Region)="PA" and allt(Last_Name)="Grant"') * Above returns * 'UPPER(REGION)="PA".AND.ALLTRIM(LAST_NAME)="Grant"' ? NORMALIZE('Employee->Birth_date > {01/01/65}') * Above returns * 'EMPLOYEE.BIRTH_DATE>{01/01/1965}' * You can apply NORMALIZE() to Expression Builder results GETEXPR "Enter Filter" TO cFilt cFilt = NORMALIZE(cFilt) IF cFilt = FILTER() * Do something ELSE * Do something different ENDIF |
See Also |