Click or drag to resize

CharOdd Function

Return the odd-numbered characters in a string.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.2a
Syntax
 FUNCTION CharOdd(
	cString AS STRING
) AS STRING
View Source

Parameters

cString
Type: String
The string whose odd-numbered characters you want to return.

Return Value

Type: String
Every other character in the string, starting from the first character.
Remarks
Examples
The SaveScreenOld() function, whose return value maintains compatibility with the CA-Clipper SaveScreen() function, stores the screen contents in a buffer such that the odd bytes contain the actual screen characters and the even bytes contain the corresponding screen attributes.  CharOdd() is useful in extracting the screen contents from such a buffer. This example saves the screen contents of the first row and redisplays it in many different colors on the next row:
X#
Function Start()
        LOCAL i AS SHORTINT
        LOCAL cBuffer AS STRING
        LOCAL cCharacters, cAttributes AS STRING
        LOCAL cSong AS STRING
        cSong := "Show me your true colors!"
        ?? cSong
        cBuffer := SaveScreenOld(0, 0, 0, 79)
        cCharacters := CharOdd(cBuffer)
        cAttributes := CharEven(cBuffer)
        // Change the attributes
        SEvalA(cAttributes, {|| Chr(i++)}, 1,;
                                SLen(cSong))
        // Redisplay with new attributes
        RestScreenOld(1, 0, 1, 79,;
                                CharMix(cCharacters, cAttributes))
        RETURN TRUE
See Also