Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper Tools . Books 1-3 - <b>wordswap()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 WORDSWAP()
 Exchanges double characters that lie beside each other in a string
------------------------------------------------------------------------------
 Syntax

     WORDSWAP(<cString>,[<lMode>]) --> cString

 Arguments

     <cString>  [@]  Designates the character string within which the 2-
     byte sequences are exchanged.

     <lMode>  Designates whether the adjoining bytes are exchanged (.T.)
     or not (.F.).  The default value (.F.) designates that the adjoining
     bytes are not exchanged.

 Returns

     WORDSWAP() returns the modified character string.

 Description

     With WORDSWAP(), 2-byte sequences within a character string are
     exchanged for each other.  In this respect the function works exactly
     like CHARSWAP(), except that 16-bit groups are being exchanged.

     The function is used on strings that contain 32-bit integers created by
     the CA-Clipper L2BIN().  The exchange serves as a preparation for a sort
     of these integers using CHARSORT().  In order to achieve a correct sort,
     you must exchange two adjacent bytes (low/high ordering of 16-bit
     integers), in addition to exchanging the 16-bit groups.

 Notes

     .  When <lMode> is .T., adjoining bytes are only exchanged after
        being exchanged as two 2-byte groups.

     .  The return value of this function can be suppressed by
        implementing CSETREF() to save working memory space.

 Examples

     .  Exchange characters:

        ? WORDSWAP("1234567890")          // "3412785690"

     .  Also exchange the bytes:

        ? WORDSWAP("1234567890, .T.)      // "4321876590"

     .  Working with L2BIN():

        ? L2BIN(1)               // 00000001 00000000 00000000 00000000
        ? L2BIN(65536)           // 00000010 00000000 00000001 00000000
        ? L2BIN(65536) > L2BIN(1)                                 // .F.
        ? WORDSWAP(L2BIN(65536), .T.) > WORDSWAP(L2BIN(1), .T.)   // .T.


See Also: CHARSWAP() CHARSORT() CSETREF()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson