Left$() 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 part or all of a string, beginning at the left end of the string. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Left$( string_expr, num_expr ) 

string_expr is a string expression.

num_expr is a numeric expression, zero or larger.

Return Value

String

Description

The Left$() function returns a string which consists of the leftmost num_expr characters of the string expression string_expr.

The num_expr parameter should be an integer value, zero or larger. If num_expr has a fractional value, MapBasic rounds to the nearest integer. If num_expr is zero, Left$() returns a null string. If the num_expr parameter is larger than the number of characters in the string_expr string, Left$() returns a copy of the entire string_expr string.

Example

Dim whole, partial As String 
whole = "Afghanistan"
partial = Left$(whole, 6)

' at this point, partial contains the string: "Afghan"

See Also:

Mid$() function, Right$() function