Sfairadora

  • Reference Guide

add_cformat

add_cformat(str, rcf)
add_cformat(str, pos, n, rcf)
add_cformat(rtxt, par, rcf)
add_cformat(rtxt, par, pos, n, rcf)
str_var <- add_cformat(rcf)
str_var <- add_cformat(pos, n, rcf)
rtxt_var <- add_cformat(par, rcf)
rtxt_var <- add_cformat(par, pos, n, rcf)
The function sets the format rcf to the specified characters of a formatted string or formatted text. The value of format attributes unspecified by the parameter rcf remain unchanged in the text (i.e. the function merges the format rcf to the original format of the characters). The first four versions of the function return the modified string/text, while the parameter str/rtxt is retained unchanged. The other four variants take a variable or data item rstr_var/rtxt_var, which they modify in place. If a position (the parameter pos) and number of characters (the parameter n) are specified, the operation affects only those characters, otherwise the whole string. If an index of a paragraph (the parameter par) is specified, the operation affects only that paragraph.
Example:
str <- add_cformat(2, 5, rcf_bold(BIT_1)|rcf_fcolor(color(200, 0, 0));
The five characters beginning with the second one are set to bold and red text color.

Parameters

str
The string in which the format is to be set (the type Rich_string).
rtxt
The text in which the format is to be set (the type Rich_text).
str_var
The variable (an l-value of the type Rich_string), containing the string in which the format is to be set.
rtxt_var
The variable (an l-value of the type Rich_text), containing the text in which the format is to be set.
par
The index of the paragraph in which the format is to be set. The paragraphs are indexed from 0.
pos
The index of the first character in the string/text/paragraph to which the format is to be set. The characters are numbered from 0. If the index is beyond the string end or is negative, an error is returned.
n
Number of character to which the format is to be set. If the character interval overlaps the end of the string, it is not an error; the change is applied to all characters up to the end of the string.
rcf
The character format to be set (the type Rich_cformat).

Return Value

The first four versions return the modified string (Rich_string)/text (Rich_text). The other return the l-value referring to the variable containing the modified string/text.

See Also