Working with display formats in the DataWindow painter  Number display formats

Chapter 21: Displaying and Validating Data

Defining display formats

Display formats are represented through masks, where certain characters have special significance. PocketBuilder supports four kinds of display formats, each using different mask characters:

For example, in a string format mask, each @ represents a character in the string and all other characters represent themselves. You can use the following mask to display phone numbers:

(@@@) @@@-@@@@

Combining formats

You can include different types of display format masks in a single format. Use a space to separate the masks. For example, the following format section includes a date and time format:

mmmm/dd/yyyy h:mm

Using sections

Each type of display format can have multiple sections, with each section corresponding to a form of the number, string, date, or time. Only one section is required; additional sections are optional and should be separated with semicolons (;).

The following format specifies different displays for positive and negative numbers; negative numbers are displayed in parentheses:

$#,##0;($#,##0)

Using keywords

Enclose display format keywords in square brackets. For example, you can use the keyword [General] when you want PocketBuilder to determine the appropriate format for a number.

Using colors

You can define a color for each display format section by specifying a color keyword before the format. The color keyword is the name of the color, or a number that represents the color, enclosed in square brackets: [RED] or [255]. The number is usually used only when a color is required that is not provided by name. The named color keywords are:

The formula for combining primary color values into a number is:

256*256*blue + 256*green + red=number

where the amount of each primary color is specified as a value from 0 to 255. For example, to specify cyan, substitute 255 for blue, 255 for green, and 0 for red. The result is 16776960.

Table 21-1 lists the blue, green, and red values you can use in the formula to create other colors.

Table 21-1: Numeric values used to create colors

Blue

Green

Red

Number

Color

0

0

255

255

Red

0

255

0

65280

Green

0

128

0

32768

Dark green

255

0

0

16711680

Blue

0

255

255

65535

Yellow

0

128

128

32896

Brown

255

255

0

16776960

Cyan

192

192

192

12632256

Light gray

Using special characters

To include a character in a mask that has special meaning in a display format, such as a square bracket ( [ ), precede the character with a backslash (\). For example, to display a single quotation mark, enter \'.

Setting display formats during execution

In scripts, you can use GetFormat to get the current format for a column and SetFormat to change the format for a column during execution.





Copyright © 2004. Sybase Inc. All rights reserved. Number display formats

View this book as PDF