Please enable JavaScript to view this site.

 

str = FormatText(sTextIn, sFormat, n32bitColor)

 

This macro function return sTextIn with markers that identify it as text that will be formatted using the format string sFormat, at a later stage, during diary generation.

 

This is an advanced function and error checking is minimal.

 

The parameters and the specifics of the return value of this function are:

 

sTextIn

This can be any text, even text that is the result of a previous call to the function FormatText (see the section on result, below, for more details). That is to say, formatting can be nested.

 

Note that if you are supplying a blank value for sTextIn, then the macro interpreter will ignore any formatting included in sFormat and emit message 188270. While this behavior makes sense for text formatting, it can cause paragraph-only or textbox-only formatting to be optimized away.

 

To avoid this issue, when using the FormatText function, always check if you are supplying a blank sTextIn parameter, and if so, replace it with a nil special character token, as shown in the example below.

if sText == ''
   sText = '&x'
endif
sResult = FormatText(sText'STYCELL(Sundays)', -1)

sFormat

Each specifier (see list in table below) is separated from the next by a comma (no space). Any value which can be specified in decimal form must use a period as decimal separator, regardless of the workstation's Windows settings.

 

A sample sFormat would be:

'B+,I+,f Times New Roman, COLOR(Pantone 231U)'

The list of the various formats supported by this function is described here.

result

The text result of this function will not be formatted text, but rather, plain text with markers that identify it for later processing.

sDate = FormatText('New Year''B+,I+,f Times New Roman', -1)

For example, the result of the above call to the function FormatText would be:

'**RICH1**New Year**TEXT1**'

At the same time a command is saved for later processing, to replace the string '**RICH1**New Year**TEXT1**' with 'New Year' in the formatting specified above.

 

If you need to get the plain text, without the markers, you can use the PeekTokenValue function.

n32bitColor

(deprecated)

Optionally, when using QuarkXPress, you can specify a color to be applied to the text, using the n32bitColor numerical value of a scanned color.

sDate = FormatText('[d]''B+, f Arial'2170914// black in scan

However, these numerical value are subject to change from one computer to the next, and we recommend that you always refer to the colors by name.

sDate = FormatText('[d]''B+, f Arial, COLOR(Pantone 231U)'-1// -1 means no color

where the value of n32bitColor is set to -1 if we want it to be ignored.Note that this option remains for backwards compatibility, but you should now use COLOR(XXX) in sFormat which refers to a colors by name, as in the example below, instead of its 32-bit representation.

sDate = FormatText('[d]''B+, f Arial, COLOR(Pantone 231U)'-1)

If the user interface language of your version of QuarkXPress is not English, then the name of the built-in colors (Black, White, Cyan, Magenta, Yellow, Red, Green, Blue) might be translated internally by QuarkXPress and therefore might not be found under its English name.

sDate = FormatText('[d]''B+, f Arial, COLOR(BLACK)'-1)

To get around this issue, you can set the name of any built-in color (Black, White, Cyan, Magenta, Yellow, Red, Green, Blue) in UPPERCASE, as in the example above, and then Q++Studio will know to look for the built-in color, not the exact name.

 

See also: FormatParagraph, native text formatting.

 


Topic 177845, last updated on 09-Oct-2024