xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

StrSwap()

Exchanges characters between two strings.

Syntax

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

Arguments

<cString1> and <cString2>
These are two character strings whose characters are exchanged from left to right. One or both parameters must be passed by reference.

Return

The function exchanges characters between <cString1> and <cString2> beginning with the first character up to the length of the shorter string. To obtain a result, at least one parameter must be passed by reference. The return value is always a null string ("").

Info

Category: CT:String manipulation , Character functions
Source:ct\strswap.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows results of StrDiff() passing either
// parameter or both by reference

   PROCEDURE Main
      LOCAL cStr1, cStr2

      cStr1 := "xHarbour compiler"
      cStr2 := "01234567"

      StrSwap( cStr1, @cStr2 )
      ? cStr1                  // result: xHarbour compiler
      ? cStr2                  // result: xHarbour

      cStr1 := "xHarbour compiler"
      cStr2 := "01234567"

      StrSwap( @cStr1, cStr2 )
      ? cStr1                  // result: 01234567 compiler
      ? cStr2                  // result: 01234567

      cStr1 := "xHarbour compiler"
      cStr2 := "01234567"

      StrSwap( @cStr1, @cStr2 )
      ? cStr1                  // result: 01234567 compiler
      ? cStr2                  // result: xHarbour

   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe