Xbasic

SQL::DataTypeInfoFormatData Method

IN THIS PAGE
This function is deprecated and may be removed in the future. Use a5_mergeDataIntoTemplate() instead.

Syntax

Formatted_Data as C = FormatData(P Row, C FormatName, P UserContext [, P RowFormatting = null_value])

Arguments

Formatted_Data

A string representation of a data value in a result set row.

Row

A SQL::Row object.

FormatName

Optional.

UserContext

Optional. The user context is passed into the evaluation of the expression when data is formatted.

RowFormatting

Pointer

Description

Return data values defined by this SQL::DataTypeInfo

Example

Return the data value defined by this SQL::DataTypeInfo as follows:

1. If a named format is provided, and a format has been set by assigning NamedFormatExpressions," this format will be used."
2. Otherwise, if the value is numeric and the DisplayFormat property has been set the value will be formatted" as if the value were passed to the system function STR using the values of DBFLength and DBFDecimals" along with the format specified in DisplayFormat"
3. Otherwise, default conversion to a string will be done.
Property
Description
.NamedFormatExpressions

This property is a CR-LF delimited list of Xbasic expressions. One of those expressions can be unnamed, subsequent expressions should be prefixed with ?=?. The Xbasic expression part of each line is executed in the context of a generated function that has three arguments:

Argument
Description
.CurrentRow

SQL::Row

.ColumnDefinition

SQL::DataTypeInfo

.Context

This value is provided by the caller and typically will be a dot variable with additional contextual information required by the expression.

.DisplayFormat

Used to specify a numeric format (where appropriate) using the values you would pass to the Xbasic str() function.

.ExternalFileNameExpression

If this string is defined when FormatData()is called:

1. FormatData()evaluates this expression to get the name of the file to create.
2. FormatData()stores the data in the file named by the expression. If the data is binary, the function stores it in binary form. The function stores all other values in string form.

SQL::Connection::ToJSON(), SQL::Connection::ToString(), and SQL::Connection::ToXML() call SQL::DataTypeInfo.FormatData()when they need formatted data values.

Example

CurrentRow.Data("CategoryID")
FileName = Context.FilePath + CurrentRow.Data("CategoryID" + "_" + ColumnDefinition.Name _ ".txt"
ShortName = Left(CurrentRow.Data("CategoryID", 4)

See Also