This function formats a numeric or character expression using the picture and function clauses available with the Format and InputMask properties.
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. |
TRANSFORM() can be a very handy way to express a special coding system—such as currency, ID numbers or stock numbers—with a defined picture, without having to store the formatting with each field. In addition, TRANSFORM() is useful as a generic translator of any type of data, as it accepts all but General and Picture fields as expressions, and always returns a character field.
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 valueDToC(), DynamicInputMask, InputMask, Format, Str(), TToC(), Val()
