[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ADDASCII()
 Adds a value to each ASCII code in a string
------------------------------------------------------------------------------
 Syntax

     ADDASCII(<cString>,<nValue>,[<nPosition>]) --> cString

 Arguments

     <cString>  [@]  Designates the character string that is processed.

     <nValue>  Designates the value that is added to the ASCII value of
     the character.

     <nPosition>  Designates the position of the character to which the
     <nValue> is added.  The default value tells CA-Clipper Tools to add to
     the ASCII value of the last character.

 Returns

     ADDASCII() returns the modified character string.

 Description

     This function is very useful when you call procedures using macros.
     When you use ADDASCII(), the string representing the macro can be
     changed without needing to include functions like LEFT(), RIGHT(),
     ASC(), or SUBSTR() (see example).

     This function also allows you to subtract a value.  However, a
     conversion is necessary.  If a lower case letter is converted into an
     upper case letter, a value of 32 must be subtracted.  This occurs
     according to the following formula:

     CHR((ASC(<Character>) + 256 - Difference) % 256)

 Notes

     .  If the <nPosition> is greater than the length of <cString> or
        less than 0, the string remains unchanged.

     .  Zero changes the value of the last character.

     .  CSETREF() can be used to suppress the returned value for this
        function in order to save space in working memory.

 Examples

     .  A value of 1 is added to the next to the last position in a
        string and to the last position in a string (CHR(ASC("2")+1) yields
        "3" etc.):

        ? ADDASCII("macro21", 1, 6)        // "macro31"
        ? ADDASCII("macro21", 1)           // "macro22"

     .  You can also subtract; -- 32 is the difference between lower
        case and upper case letters, therefore CHR((ASC("m")+256-32) %256):

        ? ADDASCII("macro21", 224, 1)      // "Macro21"


See Also: CSETREF() Introduction
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson