StrSwap()

StrSwap()

Swap the contents of two strings

Syntax

       StrSwap( <[@]cString1>, <[@]cString2> ) -> cString

Arguments

<cString1> [@] and <cString2> [@] Designate the two strings that are interchanged. At least one of the character strings must be passed by reference.

Returns

StrSwap() always returns a null string. This function only affects strings that have been passed by reference.

Description

StrSwap() interchanges the strings <cString1> and <cString2>. The exchange continues until all the characters in the shorter character string have been moved. The function terminates when the last character of the shortest string is exchanged.

Note

. The character strings are changed directly. Therefore, at least one of the strings must have been passed by reference to get a result.

Examples

       .  In this example, two strings are passed by reference:
          cStr1  :=  "1234567890"
          cStr2  :=  "ABCDEFGHIJKLM"
          ? StrSwap(@cStr1, @cStr2)      // Return value: ""
       .  The two strings subsequently contain these characters:
          ? cStr1                        // "ABCDEFGHIJ"
          ? cStr2                        // "1234567890KLM"
       .  In this example, only one of the strings is passed by
          reference:
          cStr1  :=  "1234567890"
          cStr2  :=  "ABCDEFGHIJKLM"
          ? StrSwap(cStr1, @cStr2)       // Return value: ""
       .  Both strings subsequently contain the characters of the string
          passed by reference:
          ? cStr1                        // "1234567890"
          ? cStr2                        // "1234567890KLM"

Compliance

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

Platforms

All

Files

Source is strswap.c, library is libct.

Seealso

Introduction

Advertisements

2 responses to “StrSwap()

  1. Pingback: Harbour String Functions | Viva Clipper !

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