CharMix()

CHARMIX()

Mix two strings

Syntax

      CHARMIX( <cString1>[, <cString2>] ) --> cMixedString

Arguments

<cString1> String that will be mixed with the characters from <cString2>

[<cString2>] String whose characters will be mixed with the one from <cString1>. Default: ” ” (string with one space char)

Returns

<cMixedString> Mixed string

Description

The CHARMIX() function mixes the strings <cString1> and <cString2>. To do this it takes one character after the other alternatively from <cString1> and <cString2> and puts them in the output string. This procedure is stopped when the end of <cString1> is reached. If <cString2> is shorter than <cString1>, the function will start at the begin of <cString2> again. If on the other hand <cString2> is longer than <cString1>, the surplus characters will be omitted.

Examples

      ? CHARMIX( "ABC", "123" )    // "A1B2C3"
      ? CHARMIX( "ABCDE", "12" )   // "A1B2C1D2E1"
      ? CHARMIX( "AB", "12345" )   // "A1B2"
      ? CHARMIX( "HELLO", " " )    //  "H E L L O "
      ? CHARMIX( "HELLO", "" )     //  "HELLO"

Tests

      CHARMIX( "ABC", "123" )  == "A1B2C3"
      CHARMIX( "ABCDE", "12" ) == "A1B2C1D2E1"
      CHARMIX( "AB", "12345") == "A1B2"
      CHARMIX( "HELLO", " " )   == "H E L L O "
      CHARMIX( "HELLO", "" )   == "HELLO"

Compliance

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

NOTE: CA-Tools version of CHARMIX() will hang if the second parameter is an empty string, this version will not.

Platforms

All

Files

Source is charmix.c, library is ct3.

Seealso

CHAREVEN(), CHARODD()

2 responses to “CharMix()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – C | 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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.