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


Syntax:     STUFF(<expC1>, <expN1>, <expN2>, <expC2>)

Purpose:    To delete, insert, and/or replace characters in a character
            string.

Arguments:  <expC1> is the target character string.

            <expN1> is the starting position in the target string
            where the replacement occurs.

            <expN2> is the number of characters to replace in the
            target string (<expC1>).

            <expC2> is the replacement string.

Returns:    A character string.

            Essentially STUFF() replaces <expN2> characters in the
            target string (<expC1>) beginning at <expN1> with <expC2>.

Usage:      With this basic structure STUFF() can perform the following
            six operations:

            Insert: If you specify zero for <expN2>, no characters
            are removed from <expC1>, the replacement string (<expC2>)
            is inserted at <expN1>, and the entire string is returned.

            Replace: If you specify a replacement string (<expC2>)
            the same length as <expN2>, <expC2> replaces characters
            beginning at <expN1>.

            Delete: If replacement string (<expC2>) is a null string
            (""), the number of characters specified by <expN2> are
            removed from <expC1> and the string is returned without any
            added characters.

            Replace and insert: If the replacement string (<expC2>)
            is longer than <expN2>, all characters from <expN1> are
            replaced and the rest of the replacement string (<expC2>) is
            inserted.

            Replace and delete: If the length of the replacement
            string (<expC2>) is less than <expN2>, all characters in the
            target string (<expC1>) are deleted from the end of <expC2>
            up to <expN2>.

            Replace and delete rest: If <expN2> is greater than the
            length of the target string (<expC1>), the replacement
            string (<expC2>) is inserted at <expN1> and the rest of
            <expC1> is deleted.

Library:    EXTEND.LIB

Source:     EXAMPLEC.C


----------------------------------- Examples -------------------------------

   * 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("ABCEDF", 2, 4, "xyz")   && Result: AxyzF

   * Replace and delete rest.
   ? STUFF("ABCEDF", 2, 10, "xyz")  && Result: Axyz


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

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