Click or drag to resize

CharOdd Function

X#
Return the odd-numbered characters in a string.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax
 FUNCTION CharOdd(
	cString AS STRING
) AS STRING
Request Example 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#
 1Function Start()
 2    LOCAL i AS SHORTINT
 3    LOCAL cBuffer AS STRING
 4    LOCAL cCharacters, cAttributes AS STRING
 5    LOCAL cSong AS STRING
 6    cSong := "Show me your true colors!"
 7    ?? cSong
 8    cBuffer := SaveScreenOld(0, 0, 0, 79)
 9    cCharacters := CharOdd(cBuffer)
10    cAttributes := CharEven(cBuffer)
11    // Change the attributes
12    SEvalA(cAttributes, {|| Chr(i++)}, 1,;
13                SLen(cSong))
14    // Redisplay with new attributes
15    RestScreenOld(1, 0, 1, 79,;
16                CharMix(cCharacters, cAttributes))
17    RETURN TRUE
See Also