Extract a line of text from a string.
XSharp.Core (in XSharp.Core.dll) Version: 2.7
Syntax Request Example
cString AS STRING,
nLineLength AS DWORD := 79,
nLineNumber AS DWORD := 1,
nTabSize AS DWORD := 4,
lWrap AS LOGIC := TRUE
) AS STRING
public static string MemoLine(
uint nLineLength = 79,
uint nLineNumber = 1,
uint nTabSize = 4,
bool lWrap = true
- Type: String
The string from which to extract a line of text.
- nLineLength (Optional)
- Type: UInt32
The number of characters per line.
This can be a value between 4 and 254.
The default is 79.
- nLineNumber (Optional)
- Type: UInt32
The line number to extract.
The default is 1.
- nTabSize (Optional)
- Type: UInt32
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: Boolean
TRUE toggles word wrap on; FALSE toggles it off.
The default is TRUE.
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.
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.
This example demonstrates the general method for displaying memo fields and long strings using the combination of MLCount() and MemoLine():
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)
9SET PRINTER OFF