Replaces an individual character at a particular position within a character

        [<nPosition>]) --> cString


     <cString>  [@]  Designates the character string within which the
     individual character <cCharacter|nCharacter> is substituted.

     <cCharacter|nCharacter>  Designates an individual character or a
     numeric ASCII value from 0 to 255.

     <nPosition>  Designates the position at which the character is
     substituted.  The default value is the last position in <cString>.


     The string returned is the <cString> with a <cCharacter|nCharacter>
     character in the selected position.


     POSCHAR() allows you to replace an individual character within a string
     without having to split the string.  Since this character is only
     substituted at the designated position within <cString>, the string that
     is modified can be passed by reference.


     .  The value returned by this function can be suppressed by
        implementing CSETREF() to save space in working memory.


     .  Substitute a character at position 3:

        ? POSCHAR("ABCDEF", "X", 3)   // "ABXDEF"

     .  Substitute a character in the last position:

        ? POSCHAR("ABCDEF", "X")      // "ABCDEX"

     .  Pass the string by reference:

        CSETREF(.T.)                  // Suppress return value
        cVar  := "ABCDEF"
        POSCHAR(cVar, "X")
        ? cVar                        // "ABCDEX"

See Also: CSETREF()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.