[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

     .  Configuring keys: If the <cUserFunction> is specified, the
        keys in the table below are configurable.

        MEMOEDIT() Configurable Keys
        Key            Default Action
        Ctrl+Y         Delete the current line
        Ctrl+T         Delete word right
        Ctrl+B         Reform Paragraph
        Ctrl+V/Ins     Toggle insert mode
        Ctrl+W         Finish editing with save
        Esc            Abort edit and return original

        If the key is configurable, RETURNing 0 executes the MEMOEDIT()
        default action.  RETURNing a different value, however, executes
        another key action thereby redefining the key.  If the key is not a
        configurable key recognized by MEMOEDIT(), you can define an action
        for it also by RETURNing a value requesting a key action from the
        table above.

     .  Word wrap: Word wrap is a formatting mode you can toggle by
        RETURNing 34 from the user function.  When word wrap is on (the
        default setting), MEMOEDIT() inserts a soft carriage return/line feed
        at the closest word break to the window border or line length,
        whichever occurs first.  When word wrap is off, MEMOEDIT() scrolls
        text buffer beyond the edge of the window until the cursor reaches
        the end of line.  At this point, the user must press Return
        (inserting a hard carriage return/line feed) to advance to the next

     .  Reforming paragraphs: Pressing Ctrl+B or RETURNing a 2 from a
        user function reformats the text buffer until a hard carriage return
        (end of paragraph) or the end of the text buffer is reached.  This
        happens regardless of whether word wrap is on or off.

     .  Soft carriage returns: In CA-Clipper, the insertion of soft
        carriage return/linefeed characters is never allowed to change the
        significant content of the text.  That is, when a soft carriage
        return/linefeed is inserted between two words, the space characters
        between the two words are preserved.  When text is reformatted, any
        soft carriage return/linefeed characters are removed.  This leaves
        the text in its original form and properly handles the case where a
        soft carriage return/linefeed has been inserted in the middle of a

        In the Summer '87 version of MEMOEDIT(), when a soft carriage
        return/line feed is inserted, a single space character is removed
        from the text at that point.  If the text is later reformatted using
        a different line width, each soft carriage return/linefeed is
        replaced by a single space.  However, if the text string is
        reformatted using any of the CA-Clipper text handling functions,
        words that were separated by a soft carriage return/linefeed will be
        run together because the soft carriage return/linefeed is not
        replaced with a space.

        To prevent this, text that was formatted using Summer '87 MEMOEDIT()
        should be processed to change any soft carriage return/linefeed pairs
        into space characters.  This can be accomplished using the STRTRAN()
        function as follows:

        STRTRAN( <text>, CHR(141)+CHR(10), " " )

        To convert memo values in an existing database, the following two
        line program can be used:

        USE <xcDatabase>
        REPLACE ALL <idMemo> WITH ;
           STRTRAN( <idMemo>, CHR(141)+CHR(10), " " )

        Because of the .dbt file format, replacing all occurrences of a memo
        field can cause the .dbt file to grow significantly.  The .dbt file
        can be reduced by copying the .dbf to a new file.

        For very large .dbt files, it may not be feasible to perform the
        above procedure.  The supplied utility program, DBT50.EXE located in
        \CLIP53\BIN, may be useful in these cases.  DBT50 scans an entire
        .dbt file, replacing any soft carriage return/line feed pairs with
        two spaces.  Although this has the undesirable effect of causing
        certain words to be separated by two spaces instead of one, it allows
        the file to be processed in place without using additional disk
        space.  DBT50 modifies only soft carriage return/linefeed pairs in
        the target file.  Other text is unaffected.

     .  Editing text files: MEMOEDIT() edits text files if the text
        file can be read into a CA-Clipper character variable.  This can be
        done with the MEMOREAD() function.  After editing the contents of the
        text file held in the character variable, write it back to the file
        using MEMOWRIT().


     .  This example lets you browse a memo field but prevents any
        changes to the text buffer:

        USE Customer NEW
        MEMOEDIT(CustNotes, 5, 10, 20, 69, .F.)

     .  This example allows editing of a memo field, assigning the
        changes back to the memo field:

        USE Customer NEW
        REPLACE CustNotes WITH ;
              MEMOEDIT(CustNotes, 5, 10, 20, 69)

     .  This example creates a character string using MEMOEDIT():

        LOCAL cNotes
        cNotes = MEMOEDIT()

     .  This example is a user-defined function that edits a character
        string in a boxed window displayed with a title:

     FUNCTION EditMemo( cString, cTitle,;
                 nTop, nLeft, nBottom, nRight )
           LOCAL cScreen := SAVESCREEN(nTop, nLeft,;
                 nBottom, nRight)
           @ nTop - 1, nLeft - 2 CLEAR TO nBottom + 1,;
                 nRight + 2
           @ nTop - 1, nLeft - 2 TO nBottom + 1, nRight + 2
           @ nTop - 1, nLeft SAY "[" + cTitle + "]"
           cString = MEMOEDIT(cString, nTop, nLeft,;
                 nBottom, nRight)
           RESTSCREEN(nTop, nLeft, nBottom, nRight, cScreen)

           RETURN (cString)

     .  This example reads the contents of a text file into a
        character variable, edits it, and then writes it back to disk:

        LOCAL cString := MEMOREAD("Text.txt")
        cString := MEMOEDIT(cString)
        IF !MEMOWRIT("Text.txt", cString)
           ? "Write error"

     .  This example contains a user-defined function that displays a
        message describing the current MEMOEDIT() mode.  Additionally, while
        in ME_UNKEY mode, the function will perform either a ME_WORDRIGHT or
        ME_BOTTOMRIGHT action depending on which associated function key is

        #include "Memoedit.ch"
        #include "Inkey.ch"

        PROCEDURE Main()
           USE Customer NEW
           REPLACE CustNotes WITH;
           MEMOEDIT( CustNotes, 5, 5, 15, 75, .T., "MemoUDF" )

        FUNCTION MemoUDF( nMode, nLine, nCol )
           LOCAL nKey := LASTKEY()
           LOCAL nRetVal := ME_DEFAULT         // Default return action

           DO CASE
           CASE nMode == ME_IDLE
              @ 20, 5 SAY "MemoMode is ME_IDLE  "
           CASE nMode == ME_UNKEY
              @ 20, 5 SAY "MemoMode is ME_UNKEY "
              DO CASE
              CASE nKey == K_F2
                 nRetVal := ME_WORDRIGHT
              CASE nKey == K_F3
                 nRetVal := ME_BOTTOMRIGHT
              CASE nMode == ME_UNKEYX
              @ 20, 5 SAY "MemoMode is ME_UNKEYX"
              @ 20, 5 SAY "MemoMode is ME_INIT  "

        RETURN nRetVal

 Files   Library is EXTEND.LIB, header files are Memoedit.ch and Inkey.ch.

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson