CharSwap()

CHARSWAP()

Swap neighbouring characters in a string

Syntax

      CHARSWAP( <[@]cString> ) -> cSwappedString

Arguments

<[@]cString> is the string that should be processed

Returns

<cSwappedString> a string where neighbour characters are swapped

Description

The CHARSWAP() function loops through <cString> in steps of two characters and exchanges the characters from the odd and the even positions. By setting the CSETREF() switch to .T., one can omit the return value of this functin, but one must then pass <cString> by reference.

Examples

      ? CHARSWAP( "0123456789" )   // "1032547698"
      ? CHARSWAP( "ABCDEFGHIJK" )  // "BADCFEHGJIK"

Tests

      CHARSWAP( "0123456789" )  == "1032547698"
      CHARSWAP( "ABCDEFGHIJK" ) == "BADCFEHGJIK"

Compliance

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

Platforms

All

Files

Source is charswap.c, library is libct.

Seealso

WORDSWAP(), CSETREF()

Advertisements

2 responses to “CharSwap()

  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 )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s