Click or drag to resize

MemoLine Function

X#
Extract a line of text from a string.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax
 FUNCTION MemoLine(
	cString AS STRING,
	nLineLength AS DWORD := 79,
	nLineNumber AS DWORD := 1,
	nTabSize AS DWORD := 4,
	lWrap AS LOGIC := TRUE
) AS STRING
Request Example View Source

Parameters

cString
Type: String
The string from which to extract a line of text.
nLineLength (Optional)
Type: DWord
The number of characters per line.
This can be a value between 4 and 254.
The default is 79.
nLineNumber (Optional)
Type: DWord
The line number to extract.
The default is 1.
nTabSize (Optional)
Type: DWord
The number of characters to insert when the user presses Tab.
If nTabSize is not specified, 4 spaces are inserted.
If nTabSize is greater than or equal to nLineLength, the tab size is automatically converted to nLineLength minus 1.
lWrap (Optional)
Type: Logic
TRUE toggles word wrap on; FALSE toggles it off.
The default is TRUE.

Return Value

Type: String
The line of text specified by nLineNumber in cString.
If the line has fewer characters than the indicated length, the return value is padded with blanks.
If the line number is greater than the total number of lines in cString, MemoLine() returns a NULL_STRING. If lWrap is TRUE and the indicated line length breaks the line in the middle of a word, that word is not included as part of the return value but shows up at the beginning of the next line extracted with MemoLine(). If lWrap is FALSE, MemoLine() returns only the number of characters specified by the line length.
The next line extracted by MemoLine() begins with the character following the next hard carriage return, and all intervening characters are not processed.
Remarks
MemoLine() is a memo function used with MLCount() to extract lines of text from strings and memo fields, based on the number of characters per line.
It is the most basic facility provided by X# to display memo fields and long strings. The basic method of operation is to determine the number of lines in the string using MLCount() and specifying the same number of characters per line, tab size, and wrapping behavior as you intend to use with MemoLine().
Using this value as the upper boundary of a FOR...NEXT, each line of the string can be extracted with MemoLine() and processed with any combination of output commands and functions required.
Examples
This example demonstrates the general method for displaying memo fields and long strings using the combination of MLCount() and MemoLine():
X#
1LOCAL nLineLength := 40, nTabSize := 3, lWrap := TRUE
2LOCAL nLines, nCurrentLine
3USE customer INDEX custname NEW
4nLines := MLCount(CustNotes, nLineLength, nTabSize, lWrap)
5SET PRINTER ON
6FOR nCurrentLine := 1 UPTO nLines
7    ? MemoLine(CustNotes, nLineLength, nCurrentLine, nTabSize, lWrap)
8NEXT
9SET PRINTER OFF
See Also