POSCHAR()

POSCHAR()

Replace character at a certain position within a string

Syntax

       POSCHAR(<cString>,<cCharacter|nCharacter>,
              [<nPosition>]) --> cString

Arguments

<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>.

Returns

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

Description

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.

Note

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

Examples

       .  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"

Compliance

POSCHAR() is compatible with CT3’s POSCHAR().

Platforms

All

Files

Source is pos2.c, library is libct.

Seealso

POSDEL(), POSINS(), POSREPL(), CSETREF()

Advertisements

2 responses to “POSCHAR()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – P | Viva Clipper !

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s