Asc() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
ft:locale
en-US
Product name
MapBasic
ft:title
MapInfo MapBasic Reference
First publish date
1985
ft:lastEdition
2023-09-12
ft:lastPublication
2023-09-12T16:32:32.686000

Purpose

Returns the character code for the first character in a string expression. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Asc( string_expr )

string_expr is a string expression.

Return Value

Integer

Description

The Asc() function returns the character code representing the first character in the string specified by string_expr.

If string_expr is a null string, the Asc() function returns a value of zero.

Note: All MapInfo Pro environments have common character codes within the range of 32 (space) to 126 (tilde).

On a system that supports double-byte character sets (e.g., Windows Japanese): if the first character of string_expr is a single-byte character, Asc() returns a number in the range 0 - 255; if the first character of string_expr is a double-byte character, Asc() returns a value in the range 256 - 65,535.

On systems that do not support double-byte character sets, Asc() returns a number in the range 0 - 255.

In Unicode versions of MapInfo Pro, this function operates in the system character set in a compatible manner with the non-Unicode versions of MapInfo Pro.

Example

Dim code As SmallInt
code = Asc("Afghanistan")
' code will now be equal to 65,
' since 65 is the code for the letter A

See Also:

CharVal() function, Chr$() function, Character Code Table Definitions