| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Merges the characters of two strings.
CharMix( <cString1>, <cString2> ) --> cResult
The function returns a string containing the characters of <cString1> at odd positions and those of <cString1> at even positions. This is useful, for example, to build a SaveScreen() string from a text string and video bytes.
The function operates until all characters of <cString1> are processed. It distinguishes the following situations:
| 1) | Len( <cString1> ) == Len( <cString2> ) |
| When both input strings are of the same length, each character in <cString1> is followed by the corresponding character in <cString2>. |
| 2) | Len( <cString1> ) > Len( <cString2> ) |
| When the last character of <cString2> is reached, the function starts over with the first character of <cString2>, until the last character of <cString1> is processed. |
| 3) | Len( <cString1> ) < Len( <cString2> ) |
| The function returns when the last character of <cString1> is processed. |
| See also: | CharEven(), CharOdd(), Expand(), ScreenMix() |
| Category: | CT:String manipulation , Character functions |
| Source: | ct\charmix.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example manipulates a savescreen string for changing
// the color periodically until a key is pressed
PROCEDURE Main
LOCAL cScreen, cText, cVideo
CLS
@ 2,2 SAY "Changing video bytes" COLOR "W+/B"
cScreen := SaveScreen( 2, 2, 2, 22 )
cText := CharOdd( cScreen )
cVideo := Chareven( cScreen )
DO WHILE Inkey(.5) == 0
cVideo := CharXOR( cVideo, chr(8) )
cScreen := CharMix( cText, cVideo )
RestScreen( 2, 2, 2, 22, cScreen )
ENDDO
RETURN
http://www.xHarbour.com