Chr$() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns a one-character string corresponding to a specified character code. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Chr$( num_expr ) 

num_expr is an integer value from 0 to 255 (or, if a double-byte character set is in use, from 0 to 65,535), inclusive.

Return Value

String

Description

The Chr$() function returns a string, one character long, based on the character code specified in the num_expr parameter. On most systems, num_expr should be a positive integer value between 0 and 255. On systems that support double-byte character sets (e.g., Windows Japanese), num_expr can have a value from 0 to 65,535.

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

If the num_expr parameter is fractional, MapBasic rounds to the nearest integer.

Character 12 is the form-feed character. Thus, you can use the statement Print Chr$(12) to clear the Message window. Character 10 is the line-feed character; see example below.

Character 34 is the double-quotation mark ("). If a string expression includes the function call Chr$(34), MapBasic embeds a double-quote character in the string.

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.

Error Conditions

ERR_FCN_ARG_RANGE (644) error is generated if an argument is outside of the valid range.

Example

Dim s_letter As String * 1
s_letter = Chr$(65)
Note s_letter ' This displays the letter "A"
Note "This message spans" + Chr$(10) + "two lines."

See Also:

Asc() function, ChrU$() function, Character Code Table Definitions