TrText_GetLine (function reference)

By November 1, 2017 November 13th, 2017 Online Help, Troi Text Plug-in
Troi Text Plug-in for FileMaker Pro

TrText_GetLine

Returns the n-th line of the text. The end of a line is determined by the return character ¶. This function returns all characters including the return character.

SyntaxFunction badge

TrText_GetLine ( switches ; lineNumber ; theText )

Parameters

switches(optional) determine the way the result is returned
lineNumberthe number of the line you want
theTextthe text which you want to get a line from

Switches

Switches can be empty or:

-ReturnAtEndadd a return character at the end
-Unuseduse this to make clear switches are not used, you can also use ""

Returned Result

Data type returned

Text

Result

The n-th line of text: all characters including the return character.

An empty line will result in a single return character.

If you request a line that is not in the text an empty text is returned. This makes it easy to use this function in a loop: start with line number 1 and increase until the result is empty.

Originated in

Troi Text Plug-in 1.2

Compatibility

FileMaker Pro 12 to 16

Considerations

The formatting in a layout does not alter the text field’s contents. So if a field is formatted small, the lines of that layout may be wrapped but this does not enter extra returns into the text field.
The calculation in which this function is used can be both stored and unstored. You can use this function in function definitions or in a Set Field or Set Variable script step.

Example

result = TrText_GetLine ( "-ReturnAtEnd" ; 2 ; "abc¶def¶ghi" )

this will return as result the second line: “def¶”

Example 2

We assume that in your FileMaker file the following fields are defined:

TheText		Text
gRequestedLineNo	Global, number
gLine		Global, text

Then:

TrText-GetLine ( gRequestedLineNo ; TheText )

will return the line indicated by gRequestedLineNo. This can be used in a script to extract single lines:

Set Field [ gRequestedLineNo ; 1 ]
Loop
         Set Field [ gLine ; TrText_GetLine ( "-Unused" ; gRequestedLineNo ; TheText ) ]
         Exit Loop If [ gLine = ""  ]
         Comment [ Do your stuff here... ]
         Set Field [ gRequestedLineNo ; gRequestedLineNo + 1 ]
End Loop

Example 3

Text field “Text1” consists of the following lines:
line 1
this is line 2.
line 3 is line 3!

line5 (line 4 is empty).

The result of

TrText_GetLine ( gRequestedLineNo ; Text1 )

depends on the value of gRequestedLineNo:

   gRequestedLineNo:	Returned result:       		Remarks:
   1			line 1¶
   2			this is line 2.¶
   3			line 3 is line 3!¶
   4			¶				only a return character is returned
   5			line5 (line 4 is empty).¶
   6							no more lines: result is empty
   0							invalid number: result is empty

Related topics

Troi Text Plug-in online help (overview)


Online Help Page for Troi Text Plug-in for 12 to 16 –> TrText_GetLine (textp6) 2017-1112 17:08:53