Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.3 . Guide To CA-Clipper - <b>stuff()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 STUFF()
 Delete and insert characters in a string
------------------------------------------------------------------------------
 Syntax

     STUFF(<cString>, <nStart>,
        <nDelete>, <cInsert>) --> cNewString

 Arguments

     <cString> is the target character string into which characters are
     inserted and deleted.

     <nStart> is the starting position in the target string where the
     insertion/deletion occurs.

     <nDelete> is the number of characters to be deleted.

     <cInsert> is the string to be inserted.

 Returns

     STUFF() returns a copy of <cString> with the specified characters
     deleted and with <cInsert> inserted.

 Description

     STUFF() is a character function that deletes <nDelete> characters from
     <cString> beginning at the <nStart> position.  Then, it inserts
     <cInsert> into the resulting string beginning at <nStart> to form the
     return string.  With this, STUFF() can perform the following six
     operations:

     .  Insert: If <nDelete> is zero, no characters are removed from
        <cString>.  <cInsert> is then inserted at <nStart>, and the entire
        string is returned.  For example, STUFF("My dog has fleas.", 12, 0,
        "no" ) returns "My dog has no fleas."

     .  Replace: If <cInsert> is the same length as <nDelete>,
        <cInsert> replaces characters beginning at <nStart>.  The same number
        of characters are deleted as are inserted, and the resulting string
        is the same length as the original.  For example, STUFF("My dog has
        fleas.", 12, 5, "bones") returns "My dog has bones."

     .  Delete: If <cInsert> is a null string (""), the number of
        characters specified by <nDelete> are removed from <cString>, and the
        string is returned without any added characters.  For example,
        STUFF("My dog has fleas.", 1, 3, "") returns "dog has fleas."

     .  Replace and insert: If <cInsert> is longer than <nDelete>, all
        characters from <nStart> up to <nDelete> are replaced and the rest of
        <cInsert> is inserted.  Since more characters are inserted than are
        deleted, the resulting string is always longer than the original.
        For example, STUFF("My dog has fleas.", 8, 3, "does not have")
        returns "My dog does not have fleas."

     .  Replace and delete: If the length of <cInsert> is less than
        <nDelete>, more characters are deleted than inserted.  The resulting
        string, therefore, is shorter than the original.  For example,
        STUFF("My dog has fleas.", 8, 3, "is") returns "My dog is fleas."

     .  Replace and delete rest: If <nDelete> is greater than or equal
        to the number of characters remaining in <cString> beginning with
        <nStart>, all remaining characters are deleted before <cInsert> is
        inserted.  For example, STUFF("My dog has fleas.", 8, 10, "is.")
        returns "My dog is."

 Examples

     .  These examples demonstrate the six basic operations of
        STUFF():

        // Insert
        ? STUFF("ABCDEF", 2, 0, "xyz")      // Result: AxyzBCDEF
        // Replace
        ? STUFF("ABCDEF", 2, 3, "xyz")      // Result: AxyzEF
        // Delete
        ? STUFF("ABCDEF", 2, 2, "")         // Result: ADEF
        // Replace and insert
        ? STUFF("ABCDEF", 2, 1, "xyz")      // Result: AxyzCDEF
        // Replace and delete
        ? STUFF("ABCDEF", 2, 4, "xyz")      // Result: AxyzF
        // Replace and delete rest
        ? STUFF("ABCDEF", 2, 10, "xyz")     // Result: Axyz

 Files   Library is EXTEND.LIB, source file is SOURCE\SAMPLE\STUFF.C.


See Also: RAT() RIGHT() STRTRAN() SUBSTR()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson