Skip to Content

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$="BBC BASIC(Z80)" 20 FOR i=3 TO LEN(name$) 30 PRINT LEFT$(name$,i) 40 NEXT 50 END

would print

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

Syntax

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

Associated Keywords

RIGHT$, MID$, LEN, INSTR

Last updated on