xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CharSub()

Creates a string by subtracting ASCII codes of two strings.

Syntax

CharSub( <cString1>, <cString2> ) --> cResult

Arguments

<cString1> and <cString2>
These are two-character strings whose ASCII codes are subtracted in the result string.

Return

The function returns a string by subtracting the ASCII codes of the individual characters of <cStringg2> from those of <cString1>.

Description

The function operates until all characters of <cString1> are processed. It distinguishes the following situations:

1) Len( <cString1> ) == Len( <cString2> )

  When both input strings are of the same length, the ASCII code of each character in <cString2> is subtracted from the ASCII code of the corresponding character in <cString1>.

2) Len( <cString1> ) > Len( <cString2> )

  When the last character of <cString2> is reached, the function starts over with the first character of <cString2>, until the last character of <cString1> is processed.

3) Len( <cString1> ) < Len( <cString2> )

  The function returns when the last character of <cString1> is processed.

Info

See also:AddASCII(), CharAdd(), CharAND(), CharOR(), CharXOR()
Category: CT:String manipulation , Character functions , xHarbour extensions
Source:ct\charop.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The function displays results of CharSub()

   PROCEDURE Main
      LOCAL cString := "abc"

      ? CharSub( cString, Chr(9)  )    // result: XYZ

      ? CharSub( cString, Space(3) )   // result: ABC
   RETURN

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