AscA

Description

Converts the first character of a string to its ASCII integer value.

Syntax

AscA ( string )

Argument

Description

string

The string for which you want the ASCII value of the first character


Return value

Integer.

Returns the ASCII value of the first character in string. If string is null, AscA returns null.

Usage

You can use AscA to find out the case of a character by testing whether its ASCII value is within the appropriate range. A separate function, Asc, is provided to return the Unicode code point of a character.

Examples

This statement returns 65, the ASCII value for uppercase A:

AscA("A")

This example checks if the first character of string ls_name is uppercase:

String ls_name
IF AscA(ls_name) > 64 and AscA(ls_name) < 91 THEN ...

This example is a function that converts an array of integers into a string. Each integer specifies two characters. Its low byte is the first character in the pair and the high byte (ASCII * 256) is the second character. The function has an argument (iarr) which is the integer array:

string str_from_int, hold_str
integer arraylen
 
arraylen = UpperBound(iarr)
 
FOR i = 1 to arraylen
    // Convert first character of pair to a char
    hold_str = CharA(iarr[i])
 
    // Add characters to string after converting
    // the integer's high byte to char
    str_from_int += hold_str + &
      CharA((iarr[i] - AscA(hold_str)) / 256)
NEXT

For sample code that builds the integer array from a string, see Mid.

See also

Asc

CharA

Mid

AscA method for DataWindows in the section called “AscA” in DataWindow Reference.