Transform()
This function formats a numeric or character expression using the picture and function clauses available with the Format and InputMask properties.
Usage |
cRetVal = TRANSFORM( uExpression [, cFormat ] ) |
Parameter |
Value |
Meaning |
eExpression |
Any field types except Picture and General |
Expression to be transformed. |
cFormat |
Character |
Format codes, preceded by the @ symbol, and InputMask codes. |
Omitted |
Transforms any data type sent to it with a default format, specified in the Help file. |
|
cRetVal |
Character |
A character string resulting from the formatting. |
Any attempt to TRANSFORM the contents of a Memo field by specifying a format code results in a return of the string "Memo," a useless result as far as we are concerned. Apply ALLTRIM() to the memo field to get the result you want. Omitting the format code in VFP 6 or later returns the same result as ALLTRIM()—but what's the point? |
Example |
cRetVal = TRANSFORM("6175551212", "@R (999) 999-9999" ) * Returns "(617) 555-1212" ? TRANSFORM(12345,"@B $$9,999,999") * Left-justified, floating $ sign: "$12,345" ? TRANSFORM(date(),"@E") * Returns string of format DD/MM/YY ? TRANSFORM(PRINTSTATUS(),"Y") && Displays "Y" or "N" * The hexadecimal display was introduced in VFP 5.0: ? TRANSFORM(12345, "@0") * "at zero" yields "0x00003039" * Assume that Notes is a memo field ? TRANSFORM(Notes, "@!") && Returns "Memo" - Doh! ? TRANSFORM(ALLTRIM(Notes), "@!") * Returns the memo all caps ? TRANSFORM(Notes) * In VFP 6 & 7, returns the memo value |
See Also |
DToC(), DynamicInputMask, InputMask, Format, Str(), TToC(), Val() |