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()
Pingback: Harbour String Functions | Viva Clipper !
Pingback: Harbour All Functions – P | Viva Clipper !