WordSwap()

WordSwap()

Swap neighbouring double characters in a string

Syntax

      WordSwap( <[@]cString> [, <lSwapCharacters>] ) -> cSwappedString

Arguments

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

[<lSwapCharacters>] specifies whether an additional swap should be done within the double characters Default: .F., no additional swap

Returns

<cSwappedString> a string where neighbouring double characters are swapped

Description

The WordSwap() function loops through <cString> in steps of four characters and exchanges the double characters from the first and second position with the one from the third and forth position. Additionally the function can perform a swap of the both char of each double character.

By setting the CSETREF() switch to .T., one can omit the return value of this function, but one must then pass <cString> by reference.

Examples

      ? WordSwap( "1234567890" )       // "3412785690"
      ? WordSwap( "1234567890", .T. )  // "4321876590"

Tests

      WordSwap( "1234567890" )      == "3412785690"
      WordSwap( "1234567890", .T. ) == "4321876590"

Compliance

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

Platforms

All

Files

Source is charswap.c, library is libct.

Seealso

CHARSWAP(), CSETREF()

Advertisements

2 responses to “WordSwap()

  1. Pingback: Harbour All Functions – W | Viva Clipper !

  2. Pingback: Harbour String Functions | 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