Muy buenas, tendría alguien un manual sobre pictures, es decir, todos los posibles pictures que tengamos.
Un Saludo.
Muy buenas, tendría alguien un manual sobre pictures, es decir, todos los posibles pictures que tengamos.
Un Saludo.
TRANSFORM()
Convert any value into a formatted character string
------------------------------------------------------------------------------
Syntax
TRANSFORM(<exp>, <cSayPicture>) --> cFormatString
Arguments
<exp> is the value to be formatted. This expression can be any
valid CA-Clipper data type except array, code block, and NIL.
<cSayPicture> is a string of picture and template characters that
describes the format of the returned character string.
Returns
TRANSFORM() converts <exp> to a formatted character string as defined by
<cSayPicture>.
Description
TRANSFORM() is a conversion function that formats character, date,
logical, and numeric values according to a specified picture string that
includes a combination of picture function and template strings.
TRANSFORM() formats data for output to the screen or the printer in the
same manner as the PICTURE clause of the @...SAY command.
¦ Function string: A picture function string specifies
formatting rules that apply to the TRANSFORM() return value as a
whole, rather than to particular character positions within <exp>.
The function string consists of the @ character, followed by one or
more additional characters, each of which has a particular meaning
(see table below). If a function string is present, the @ character
must be the leftmost character of the picture string, and the
function string must not contain spaces. A function string may be
specified alone or with a template string. If both are present, the
function string must precede the template string, and the two must be
separated by a single space.
TRANSFORM() Functions
---------------------------------------------------------------------
Function Action
---------------------------------------------------------------------
B Displays numbers left-justified
C Displays CR after positive numbers
D Displays date in SET DATE format
E Displays date in British format
R Nontemplate characters are inserted
X Displays DB after negative numbers
Z Displays zeros as blanks
( Encloses negative numbers in parentheses
! Converts alphabetic characters to uppercase
---------------------------------------------------------------------
¦ Template string: A picture template string specifies
formatting rules on a character-by-character basis. The template
string consists of a series of characters, some of which have special
meanings (see table below). Each position in the template string
corresponds to a position in the value of the <exp> argument.
Because TRANSFORM() uses a template, it can insert formatting
characters such as commas, dollar signs, and parentheses.
Characters in the template string that have no assigned meanings are
copied literally into the return value. If the @R picture function
is used, these characters are inserted between characters of the
return value; otherwise, they overwrite the corresponding characters
of the return value. A template string may be specified alone or
with a function string. If both are present, the function string
must precede the template string, and the two must be separated by a
single space.
TRANSFORM() Templates
---------------------------------------------------------------------
Template Action
---------------------------------------------------------------------
A,N,X,9,# Displays digits for any data type
L Displays logicals as "T" or "F"
Y Displays logicals as "Y" or "N"
! Converts an alphabetic character to uppercase
$ Displays a dollar sign in place of a leading space in a
numeric
* Displays an asterisk in place of a leading space in a
numeric
. Specifies a decimal point position
, Specifies a comma position
---------------------------------------------------------------------
Examples
¦ This example formats a number into a currency format using a
template:
? TRANSFORM(123456, "$999,999") // Result: $123,456
¦ This example formats a character string using a function:
? TRANSFORM("to upper", "@!") // Result: TO UPPER PICTURE: When you specify the PICTURE clause for a GET, the
character string specified by <cGetPicture> controls formatting and edit
validation. The picture string controls the display format like a SAY
picture. It also controls the way the user can edit the buffer. A
picture string consists of two distinct parts, a function string and a
template string, either or both of which may be present.
¦ Function string: A PICTURE function string specifies
formatting or validation rules which apply to the GET's display value
as a whole, rather than to particular character positions within it.
The function string consists of the @ character, followed by one or
more additional characters, each of which has a particular meaning
(see the following table). The function string must be the first
element of a PICTURE clause and cannot contain spaces. A function
string may be specified alone or with a template string. If both are
present, the function string must precede the template string, and
the two must be separated by a single space.
GET PICTURE Format Functions
---------------------------------------------------------------------
Function Type Action
---------------------------------------------------------------------
A C Allows only alphabetic characters.
B N Displays numbers left-justified.
C N Displays CR after positive numbers.
D D,N Displays dates in SET DATE format.
E D,N Displays dates with day and month inverted
independent of the current DATE SETting, numerics
with comma and period reverse (European style).
K ALL Deletes default text if first key is not a cursor
key.
R C Nontemplate characters are inserted in the display
but not saved in the variable.
S<n> C Allows horizontal scrolling within a GET. <n> is
an integer that specifies the width of the region.
X N Displays DB after negative numbers.
Z N Displays zero as blanks.
( N Displays negative numbers in parentheses with
leading spaces.
) N Displays negative numbers in parentheses without
leading spaces.
! C Converts alphabetic character to uppercase.
---------------------------------------------------------------------
¦ Template string: A PICTURE template string specifies
formatting or validation rules on a character by character basis.
The template string consists of a series of characters, some of which
have special meanings (see the following table). Each position in
the template string corresponds to a position in the displayed GET
value. Characters in the template string that do not have assigned
meanings are copied verbatim into the displayed GET value. If you
use the @R picture function, these characters are inserted between
characters of the display value, and are automatically removed when
the display value is reassigned to <idVar>; otherwise, they overwrite
the corresponding characters of the display value and also affect the
value assigned to <idVar>. You may specify a template string alone
or with a function string. If you use both, the function string must
precede the template string, and the two must be separated by a
single space.
GET PICTURE Template Symbols
---------------------------------------------------------------------
Template Action
---------------------------------------------------------------------
A Allows only alphabetic characters
N Allows only alphabetic and numeric characters
X Allows any character
9 Allows digits for any data type including sign for
numerics
# Allows digits, signs and spaces for any data type
L Allows only T, F, Y or N
Y Allows only Y or N
! Converts an alphabetic character to uppercase
$ Displays a dollar sign in place of a leading space in a
numeric
* Displays an asterisk in place of a leading space in a
numeric
. Displays a decimal point
, Displays a comma
---------------------------------------------------------------------Muchas gracias, esto es muy util.
Un Saludo.
Muchas gracias.
ALGUNOS EJEMPLITOS UTILES
FUNCTION Start() AS VOID
LOCAL nNumber AS FLOAT
// Transform examples
? Transform(123.45,"@B 99999.99")
? Transform(3.45,"@B 99999.99")
? Transform(123.45,"@C 99999.99")
? Transform(-123.45,"@X 99999.99")
? Transform(123.45,"@Z 99999.99")
? Transform(0,"@Z 99999.99")
? Transform(0,"99999.99")
? Transform(-123.45,"@( 99999.99")
? Transform(-123.45,"@(XC 99999.99")
// Date/time examples
? ElapTime("03:02:01", "09:09:09") // 06:07:08
? ElapTime("09:05:12", "23:10:07") // 14:04:55
? Time24(), AmPm(Time24())
SetAMExt(" am")
SetPMExt(" pm")
SetAmPm(TRUE)
? Today(), DToS(Today()), DToC(Today()), DoW(Today()), Day(Today()), CDoW(Today())
? Days(300000)
? TString(303600)
? TString(10400)
// String examples
? "1234567890123456"
? Str(5.4500,12,-1)
? Str(123.458,12,2)
? Str(234.4563456456,12,-1)
? Str(234.4563456456,12,2)
? Str(23.5,10,5)
SetScience(TRUE)
? Str(353425234.56746,-1)
nNumber := 123.45
? Str(nNumber) // 123.45
? Str(nNumber, 4) // 123.
? Str(nNumber, 2) // **
? Str(nNumber * 10, 7, 2) // 1234.50
? Str(nNumber * 10, 12, 4) // 1234.5000
? Str(nNumber, 10, 1) // 123.5
? Str(123.45, -1) // 123.45
? Str(123.45, -1, 2) // 123.45
? Str(0.45000, 14, -1) // 0.45000
? Str(5.45000, 14, -1) // 5.45000
? Str(5.4500, 14, -1) // 5.4500
// Insert
? Stuff("ABCDEF", 2, 0, "xyz") // AxyzBCDEF
// Replace
? Stuff("ABCDEF", 2, 3, "xyz") // AxyzEF
// Delete
? Stuff("ABCDEF", 2, 2, "") // ADEF
// Replace and insert
? Stuff("ABCDEF", 2, 1, "xyz") // AxyzCDEF
// Replace and delete
? Stuff("ABCDEF", 2, 4, "xyz") // AxyzF
// Replace and delete rest
? Stuff("ABCDEF", 2, 10, "xyz") // Axyz
RETURN
? str( 324.6666334, 16, -1 ) // 325
? str( 324.6666334, -1 ) // 325
? str( 324.6666334, -1, 5 ) // 324,66663Syntax
Str( <nNumber> , ;
[<nLength>] , ;
[<nDecimals>], ;
[<lTrim>] ) --> cString
Arguments
<nNumber>
A numeric value to convert to a character string.
<nLength>
An optional numeric value specifying the length of the return string, including sign and decimal places.
<nDecimals>
This is an optional numeric value indicating the number of decimal places to return.
<lTrim>
This parameter defaults to .F. (false). When .T. (true) is passed, the returned string has no leading spaces. Return
The function returns <nNumber> formatted as a character string.Patricio,
gracias por la respuesta, pero lo que no encontré documentado es el uso del -1 como parámetro, que tampoco me lo explica la definición que pusiste.
Un saludo