Adds a value to each ASCII code in a string

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


     <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 Clipper Tools to add to
     the ASCII value of the last character.


     ADDASCII() returns the modified character string.


     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)


     .  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.


     .  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"


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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.