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"
Status

Ready

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.

See Also