[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|              MLINE              |
+---------------------------------+
MLINE(<memo field>, <expN1>
        [, <expN2>]

-----------------------------------
Returns specific line from a specified memo field.
Return value - Character
-----------------------------------

The MLINE() function returns a specific line from a memo field.  The
length of the lines and the number of lines within a memo field is
determined by the current value of SET MEMOWIDTH (the default value is
50).

When searching a memo field for a character string, you may use the
ATLINE() or ATCLINE() functions to return the line number where the
character string is found.  Use this line number in MLINE() to return
the contents of the line from the memo field.

<memo field>
        MLINE() returns a line from the <memo field> you specify.  If the memo
field is in a database that isn't open in the currently selected work
area, preface the memo field with a period and the database alias.

<expN1>
        The numeric expression <expN1> is number of the line to be returned
from the memo field.  If <expN1> is zero or greater than the number of
lines in the memo field, the null string is returned.

<expN2>
        The optional numeric expression <expN2> is the offset from the
beginning of the memo field line.  The _MLINE system memory variable is
typically used for <expN2>.  _MLINE is automatically incremented each
time the MLINE() function is called.

        In recursive procedures that return lines from large memo fields, best
performance can be obtained by including _MLINE as <expN2>.

+---------------------------------+
|         Program Example         |
+---------------------------------+
In the example below, two methods are used to return lines from a memo
field.  A new record is added to the CUSTOMER database, and its memo
field is filled.  Two loops use MLINE() to return lines from the memo
field.  Note the improvement in performance in the second loop when the
_MLINE system memory variable is used in MLINE().

CLEAR
SET TALK OFF
SET MEMOWIDTH TO 50
CLOSE ALL
USE customer  && Open customer database
APPEND BLANK  && Add a record
@ 2,2 SAY 'Filling memo field...'
*** Fill the memo field  ***
FOR outerloop = 1 TO 5  &&  loop 5 times
        FOR alphabet = 65 TO 90  &&  letters A to Z
                REPLACE comments WITH REPLICATE(CHR(alphabet), 40) ;
                        + CHR(13) ADDITIVE
        NEXT
NEXT

*** Display all lines from the memo field ***
STORE MEMLINES(comments) TO numlines  && Number of lines in memo field
STORE SECONDS() TO begin     &&  Beginning time
FOR count = 1 TO numlines  &&  Loop for number of lines in memo field
        ?MLINE(comments, count)      &&  Display each line
NEXT
? STR(SECONDS() - begin, 4, 2) + ' seconds'  && Total time
*** Preferable method using _MLINE in MLINE() ***
*** Display all lines from the memo field ***
WAIT 'Press a key to see the preferred method' WINDOW
CLEAR
STORE 0 TO _MLINE                && Reset _MLINE to zero
STORE SECONDS() TO begin        && Beginning time
FOR count = 1 TO numlines  && Loop for number of lines in memo field
        ?MLINE(comments, 1, _MLINE)  &&  Display each line
NEXT
? STR(SECONDS() - begin, 4, 2) + ' seconds'  && Total time
SET TALK ON

-----------------------------------

See Also:  ATCLINE(), ATLINE(), COPY MEMO, MEMLINES(), _MLINE, MODIFY
MEMO, SET MEMOWIDTH

-----------------------------------

See Also: ATCLINE() ATLINE() COPY MEMO MEMLINES() MODIFY
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson