Function Var2Char() Foundation
Converts a variable to it's string representation.
Var2Char( <xValue> ) --> cString
The function returns the string representation of the passed value, regardless of locale specific settings.
Var2Char() is used to convert values of any data type, be it simple or complex data types, to a string representation. It ignores any locale specific settings and is the inverse function of Char2Var(). Note, however, that Char2Var() cannot convert the string representation of complex data types (Array, Code block, Object) to the original data type. If this is required, the functions Var2Bin() and Bin2Var() must be used.
// The example demonstrates the result of Var2Char()
// for values of all data types.
PROCEDURE Main
LOCAL aArray := { 1, "A" }
LOCAL bBlock := {|x| x + 1 }
LOCAL cString := "Hello World"
LOCAL dDate := Date()
LOCAL lOk := .T.
LOCAL nNumber := 123.456
LOCAL oGet := Get():new()
LOCAL uNil := NIL
? Var2Char( aArray ) // result: {1, A}
? Var2Char( bBlock ) // result: {|x| x + 1 }
? Var2Char( cString ) // result: Hello World
? Var2Char( dDate ) // result: 20000426
? Var2Char( lOk ) // result: T
? Var2Char( nNumber ) // result: 123.456
? Var2Char( oGet ) // result: Get
? Var2Char( uNil ) // result: NIL
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.