Advanced Syntax Example

To clarify the advanced form of the coldef syntax, consider this example:

COLDEF="0~0~x~H~Font=Playbill~~"                          ! row font #1

COLDEF=COLDEF+"0~0~x~H~Font=,2048~Scale=200~~"            ! row font #2

COLDEF=COLDEF+"0~0~x~H~HdrFont=Times Roman~~"             ! Header font

COLDEF=COLDEF+"0~0~x~H~HdrScale=150~~"                    ! Header scale

COLDEF=COLDEF+"1~1~x~fH~~"                                ! font column

COLDEF=COLDEF+"2~1~x~cH~~"                                ! color column

COLDEF=COLDEF+"3~15~PO #~SK~~"                            ! col 1

COLDEF=COLDEF+"18~10~Order"+chr(13)+chr(10)+"Date~D|~~"   ! col 2

COLDEF=COLDEF+"29~12~Amount~#~Dspmin=6~~"                 ! col 3

COLDEF=COLDEF+"52~40~Notes~SMW3~RGBfg=240,20,50~~         ! col 4"

 

This defines four pseudo columns (for the purposes of defining two row fonts, a header font style and a header font scale), plus two special controls columns (font and color) which do not display but which do contain data, and four visible data columns.

Note that pseudo column definitions should start with "0~0~x~H~" (position 0, width 0, title "x", type "H"). The title and type specifiers do not actually matter, since the pseudo column is not displayed and contains no data, but they must be non-null, because two adjacent tildes marks the end of the column definition.

Of the visible data columns, the first is supplied by the character positions 3 through 17 of the data source records (array or file), has a title of "PO #", contains string data, (left justified by default) and may not be reordered. The second occupies positions 18-27 of the source data record, has a title of "Order Date" (broken into two lines), contains dates using the format mm/dd/yr (or dd/mm/yr, depending on the language definition), and is center justified. The third occupies positions 29-40 of the source records, has a title of "Amount", contains numeric data (right justified by default), and has a minimum width of 6 standard character cells. The last column comes from positions 52-91 of the source records, has a title of "Notes", contains string data, supports both explicit line breaks (embedded CRLF) and also auto-wrap based.. It also specifies a custom text color RGB(240,20,50). Note that the last column width will always be set to accommodate the longest cell data, so the auto wrap option wo not have any effect, unless the column is moved by the user (via drag and drop on the column header), in which case it can be resized and the wrap will have a significant effect.

Regarding the last column, note that because its definition starts in position 52 of the input data, while the previous column ended in position 40, the input data in positions 41-51 will be ignored (not loaded into the control, even in a hidden column). The display width setting of 20 refers to standard character cells (which are typically larger than the average proportional-font character width) so the column may display more or less than twenty characters for reach record. There is probably not much point in limiting it to twenty in this example, since it is the last column anyway. The only effect of the setting would be to limit how much screen space the column takes up when the control is scrolled all the way to the right. See the xtrctl XTR'ITEMLINES and XTR'TRUNCATED parameters and flags XTF_VARY, which affect how the column will deal with contents that does not fit in the display area provided.