{{fbdoc item="title" value="LEFT"}}----
Returns the leftmost substring of a string

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Left** ( [[KeyPgByref|byref]] //str// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]], [[KeyPgByval|byval]] //n// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] [[KeyPgString|string]]
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Left** ( [[KeyPgByref|byref]] //str// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgWstring|wstring]], [[KeyPgByval|byval]] //n// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] [[KeyPgWstring|wstring]]
##
{{fbdoc item="usage"}}##
	//result// = **Left**[$]( //str//, //n// )
##
{{fbdoc item="param"}}
	##//str//##
		The source string.
	##//n//##
		The number of characters to return from the source string.

{{fbdoc item="ret"}}
	Returns the leftmost substring from ##//str//##.

{{fbdoc item="desc"}}
	Returns the leftmost ##//n//## characters starting from the left (beginning) of ##//str//##. If ##//str//## is empty, then the null string (##"####"##) is returned. If ##//n// <= 0## then the null string (##"####"##) is returned. If ##//n// > len(//str//)## then the entire source string is returned.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/strings/left.bas"}}%%(freebasic)
dim text as string = "hello world"
print left(text, 5)
%%
	will produce the output:

%%hello
%%
An Unicode example:
<<
dim text as wstring*20
text = "&#1055;&#1088;&#1080;&#1074;&#1077;&#1090;, &#1084;&#1080;&#1088;!"
print left(text, 6) 'displays "&#1055;&#1088;&#1080;&#1074;&#1077;&#1090;"
<<::c::

{{fbdoc item="target"}}
	- DOS does not support the wide-character string version of **##Left##**.

{{fbdoc item="lang"}}
	- The string type suffix "$" is obligatory in the //[[CompilerOptlang|-lang qb]]// dialect.
	- The string type suffix "$" is optional in the //[[CompilerOptlang|-lang fblite]]// dialect.
	- The string type suffix "$" is forbidden in the //[[CompilerOptlang|-lang fb]]// dialect.

{{fbdoc item="diff"}}
	- QB does not support Unicode.

{{fbdoc item="see"}}
	- ##[[KeyPgRight|Right]]##
	- ##[[KeyPgMidfunction|Mid (Function)]]##

{{fbdoc item="back" value="CatPgString|String Functions"}}