4D v13.4TEXT TO ARRAY |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v13.4
TEXT TO ARRAY
TEXT TO ARRAY
The TEXT TO ARRAY command transforms a text variable into a text array. The original varText text (styled or not) is divided and each part becomes an element of the arrText array that is returned by the command. This command can be used for example to fill pages or columns with text of a set size. The original text is divided into "words" based on a line size defined by the command parameters and which takes any styles used into account. In the varText parameter, you pass the text to be divided into array elements. This text may or may not be multistyle. Some parameters are ignored when the text is multistyle. In the arrText parameter, you pass the name of the array to be filled by the divided text. In the width parameter, you pass a size in pixels indicating the maximum line length to measure when dividing the text. For the entire text, the command evaluates the maximum number of words that can "fit" into this width based on the graphic attributes of the text (font, style).
Each array element must contain at least one word. If the width passed is too small for the dividing rule to be strictly respected, the array is filled as close as possible according to the parameters and the OK variable is set to 0. For example, if you pass a width of 3 pixels, it is probable that most of the words will be bigger than this length. In this case, the OK variable is set to 0. In the fontName and fontSize parameters, you pass the font name and size with which varText must be evaluated by the command in order to divide it. These parameters are mandatory in the case of raw text. In the fontStyle parameter, you pass one or more constants from the Font Styles theme:
This parameter is optional; when it is omitted, the Normal style is used. The optional * parameter, if passed, forces the fontName, fontSize and/or fontStyle parameters to be taken into account for multistyle text when these parameters are not defined in the original text. However, if these parameters are defined in the original text, then the parameters passed to the command are ignored in all cases. We want to divide a multistyle text into lines with a maximum size of 200 pixels: TEXT TO ARRAY(theText;TextArray;200;"Arial";20;Normal;*) We want to divide raw text into lines with a maximum size of 350 pixels in Bodoni Bold font, size 14. Since the command does not work correctly if the font is not available, it is important to check for its presence: ARRAY TEXT($FontList;0) Multistyle text must be printed without any styles in Arial Normal font, size 12 with a maximum width of 600 pixels: // we transform the multistyle text into raw text You need to print in a 400-pixel wide area, a text with a maximum of 80 lines and using the largest font possible (without exceeding 24 points). You can write: ARRAY TEXT(TextArray;0) |
PROPERTIES
Product: 4D
INDEX HISTORY
SEE ALSO
OBJECT Get plain text |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||