Skip to content

LEFT$

Syntax

LEFT$ (X$, I)

Description

Returns a string comprised of the leftmost I characters of X. I must be in the range 0 to 255. If I is greater than LEN(X), the entire string (X$) will be returned. If I=0, the null string (length zero) is returned.

Example

10 A$ = "BASIC-80"
20 B$ = LEFT$(A$, 5)
30 PRINT B$
RUN
BASIC
Ok

See Also

  • ASC - Returns a numerical value that is the ASCII code of the first character of the string X$
  • CHR$ - Returns a one-character string whose ASCII code is the specified value
  • HEX$ - Returns a string which represents the hexadecimal value of the decimal argument
  • INSTR - Searches for the first occurrence of string Y$ in X$ and returns the position at which the match is found
  • LEN - Returns the number of characters in X$
  • MID$ - Extract a substring from the middle of a string
  • MID$ Assignment - Replace characters within a string variable
  • OCT$ - Returns a string which represents the octal value of the decimal argument
  • RIGHT$ - Return the rightmost N characters from a string
  • SPACE$ - Returns a string of I spaces
  • SPC - Prints I blanks on the terminal
  • STR$ - Convert a number to its string representation
  • [STRING](string_dollar.md) - Returns a string of length I whose characters all have ASCII code J or the first character of X
  • VAL - Returns the numerical value of string X$