# TRANSFORM()

Formats a value based on a specific picture template.

Syntax

  TRANSFORM( <xExpression>, <cTemplate> ) --> cFormated

Arguments

  <xExpression> Any expression to be formated.
  <cTemplate> Character string with picture template

Returns

  <cFormated> Formatted expression in character format

Description

  This function returns <xExpression> in the format of the picture expression passed to the function as <cTemplate>.
  Their are two components that can make up <cTemplate> : a function string and a template string.Function strings are those functions that globally tell what the format of <xExpression> should be.These functions are represented by a single character precede by the @ symbol.
  There are a couple of rules to follow when using function strings and template strings:
  - First, a single space must fall between the function template and the template string if they are used in conjunction with one another.
  - Second,if both components make up the value of <cTemplate>,the function string must precede the template string.Otherwise,the function string may appear with out the template string and vice versa.
  The table below shows the possible function strings avaliable with the TRANSFORM() function.

@B | Left justify the string within the format.
@C | Issue a CR after format is numbers are positive.
@D | Put dates in SET DATE format.
@E | Put dates in BRITISH format.
@L | Make a zero padded string out of the number.
@R | Insert nontemplate characters.
@X | Issue a DB after format is numbers are negative.
@Z | Display any zero as blank spaces.
@( | Quotes around negative numbers
@! | Convert alpha characters to uppercased format.

  The second part of <cTemplate> consists of the format string.Each character in the string may be formated based on using the follow characters as template markers for the string.

A,N,X,9,# | Any data type
L | Shows logical as "T" or "F"
Y | Shows logical as "Y" or "N"
! | Convert to uppercase
$ | Dolar sing in place of leading spaces in numeric expression
* | Asterisks in place of leading spaces in numeric expression
, | Commas position
. | Decimal point position

Examples

          LOCAL cString := 'This is harbour'
          LOCAL nNumber := 9923.34
          LOCAL nNumber1 := -95842.00
          LOCAL lValue := .T.
          LOCAL dDate := DATE()
          ? 'working with String'
          ? "Current String is", cString
          ? "All uppercased", TRANSFORM( cString, "@!" )
          ? "Date is", ddate
          ? "Date is ", TRANSFORM( ddate, "@D" )
          ? TRANSFORM( nNumber, "@L 99999999" )  //  "009923.34"
          ? TRANSFORM( 0      , "@L 9999"     )  //  "0000"

    Tests
          See regression Test

Status

  Ready

Compliance

  The @L function template is a FOXPRO/Xbase Extension

Platforms

  All

Files

  Library is rtl

See Also

- @...SAY
- DEVOUTPICT()