style()

Function group Execute on client Platform(s)
String YES All

Syntax

style(textescape[,value])

Description

Returns a style sequence suitable for embedding in styled text. textEscape is a kEsc... constant; value is a suitable value for the particular textEscape.

Valid constants for the style-character are listed under 'Text escapes' in the Constants pane of the IDE Catalog window (there is also a group called 'JavaScript text escapes' for the JavaScript client). Depending on the style character, you may also need to specify a value, which itself can be a constant. You can use this function to format the columns in a headed list box field; in this case, you can insert an icon by specifying its ID, change the text color, or set a text style such as italic. 

Note that the alignment escapes (kEscCTab, kEscLTab and kEscRTab) are not designed to work with the headed list box. The headed list box method $setcolumnalign() can be used to set the alignment of a column.

The JavaScript client supports a subset of the standard text escapes, and some additional values specific to the JavaScript client, as documented by the following table:

kEscColor In a client-executed method, the color parameter must be a numeric literal or constant.
kEscStyle In a client-executed method, the style parameter must be a numeric literal or constant.
kEscBmp In a client-executed method, the icon id parameter must be either a numeric literal, or the sum of a numeric literal and an icon size constant e.g. 1710+k48x48
kEscJsNewline No additional parameters are required. Inserts a <br> line break tag. There is also a new function br() which can be used as short-hand to do this.
kEscJsClose No additional parameters are required. Closes the current open style information (inserted by kEscColor or kEscStyle) in the styled text and reverts to the original color and text style. Note -kEscColor and kEscStyle insert a <span> tag to style the text. kEscJsClose closes the <span> tag.
kEscJsHtml Inserts raw HTML (the second parameter to style()).

Example

; to format the columns in a headed list box you could use the following calculation
Do con(
lCol1,style(kEscBmp,1756),kTab,lCol2,style(kEscColor,kRed),kTab,lCol3,style(kEscStyle,kItalic))
; give lCol1 a blue spot icon, lCol2 is red and lCol3 italic