function
Topic group Related topics Example
Formats text in an object.
Property of
Entryfield, SpinBox, Text
Description
Use a formatting function to format the display and entry of data. While a picture gives you character-by-character control, a function formats the entire value.
dBASE Plus recognizes the following function symbols:
Symbol |
Description |
( |
Encloses negative numbers in parentheses without the minus sign. |
! |
Converts letters to uppercase. |
# |
Restricts entries to numbers, signs, spaces and the SET POINT character. |
^ |
Displays numbers in exponential form. |
$ |
Displays data in currency format which displays the currency symbol right before or right after the value (depending on the current setting of SET CURRENCY LEFT|RIGHT) |
A |
Restricts entry to alphabetic characters. |
B |
Left-aligns a numeric entry within the maximum width of the value. |
C |
Displays CR (credit) after a positive number. |
D |
Displays and accepts entry of a date in the current SET DATE format. D should be the last function code when used with other function codes. |
E |
Displays and accepts entry of a date in European (DD/MD/YY) format. E should be the last function code when used with other funciton codes. |
I |
Centers the entry. |
J |
Right-aligns the entry. |
L |
Displays numbers with leading zeros. Overrides the $ function code and the $ and * picture codes. |
R |
Inserts literal placeholders, characters that are not template codes, into the display without storing them in the field. Literal placeholders, included after the R function code in a picture template, will be displayed with the value but will not be stored as data for the object. For example, if the value of a field named "Phone" is 4155551212, a template of "@R (999) 999-9999" displays the phone number as (415) 555-1212 but stores it as 4155551212. R must be the last function code if it is used with other function codes. |
S<n> |
Limits width of displayed value to <n> characters and horizontally scrolls the characters within it up to <n> columns. <n> must be a literal positive number. |
T |
Removes leading and trailing spaces from character values. |
V<n> |
? and ?? command only: Wraps a character string within a width specified by <n>. |
X |
Displays DB (debit) after a negative number. |
Z |
Displays zeros as a blanks. |
Function codes are restricted according to the data types to which they apply:
• The functions $, (, C, L, X, and Z can be used only with numeric values or character data that is restricted via its picture template characters to characters that can be entered for numeric data.
• E applies only to date data.
• !, #, A, D, R, S, and T are relevant only to character data.
You can use some format functions in combination. For example, the function XC displays DB after negative numbers and CR after positive numbers. However, you cannot use some functions together, such as D and E.
The $ function displays the value or expression with the currency symbol immediately before or after the amount. The currency symbol, the symbol's placement (before or after the amount), the separator characters, and the decimal symbol can be changed with the SET CURRENCY, SET SEPARATOR, and SET POINT commands.
Use S (with no space between S and <n>) to limit the display of character data to n characters. The number of columns you specify, by the literal integer <n>, must be less than the actual length of the character value or datalinked character field or memory variable.
Do not put any spaces between the S and the integer, and do not include the angle brackets (<>).
The string scrolls within the specified width, allowing you to view and edit the entire character string. Use Left Arrow, Right Arrow, Home, and End to bring hidden characters into view. When you are entering data, the string scrolls automatically.
The B, I, and J functions trim and align fields within the maximum width for either a specified PICTURE template or if none is specified, for a default template generated internally by dBASE.
The width of the default template will be one of the following:
For a datalinked control, the maximum width of the datalinked field
For an Entryfield or Spinbox without a datalink:
- For a numeric value, the maximum width for a high precision value (34 digits)
- For a character value, the width of the value including any leading or trailing spaces
For a TEXT object, or a value formatted within a ? command or Transform() function, the width of the actual value including any leading or trailing spaces.
If you specify no alignment, strings are left-aligned and numbers right-aligned.
Note - The above function formatting codes can also be used:
- Within a component's picture property
- Within the FUNCTION or PICTURE clauses of the ? and ?? commands
- Within the second parameter passed to the Transform() function which specifies a picture template
Note - You may include function symbols in a picture template by preceding them with the @ symbol. If you combine template characters and function symbols in the same template, list function symbols first and separate them from the template characters with a space.