LEFT$

A string function which returns the left 'num' characters of the string. If there are insufficient characters in the source string, all the characters are returned.

There must not be any spaces between LEFT$ and the opening bracket.

newstring$=LEFT$(A$,num)
A$=LEFT$(A$,2)
A$=LEFT$(RIGHT$(A$,3),2)

For example,

10 name$="BBCBASIC(Z80)"
20 FOR i=3 TO 14
30   PRINT LEFT$(name$,i)
40 NEXT
50 END

would print

BBC
BBCB
BBCBA
BBCBAS
BBCBASI
BBCBASIC
BBCBASIC(
BBCBASIC(Z
BBCBASIC(Z8
BBCBASIC(Z80
BBCBASIC(Z80)
BBCBASIC(Z80)

Syntax

<s-var>=LEFT$(<str>,<numeric>)

Associated Keywords