Left: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.''
Left(''string'', ''length'')
Left(''string'', ''length'')


== Description ==
== Description ==


Left returns a string containing a specified number of characters from the left end of a string. The required parameter, ''string'', is any valid string expression. The required parameter, ''length'', is any valid numeric expression, if length is 0, an empty string ("") is returned, if length is greater than the size of string, the entire string is returned.
Left returns a string containing a specified number of characters from the left end of a string. The required parameter, ''string'', is any valid string expression. The required parameter, ''length'', is any valid numeric expression. If ''length'' is 0, an empty string ("") is returned. If ''length'' is greater than the size of ''string'', the entire string is returned.


== Example (Basic) ==
== Example (Basic) ==
Line 17: Line 19:
Print "The Left 4 of " & Eric & ": " _
Print "The Left 4 of " & Eric & ": " _
   & Left(Eric, 4)
   & Left(Eric, 4)
</pre>
== Example (JavaScript) ==
<pre>
// Left Example
/* Left returns substring from string left end */
var Wendy, Eric;
Wendy = "Testaburger";
Eric = "Cartman";
NSB.Print("The Left 4 of " + Wendy + ": " + Wendy.substring(0,4));
NSB.Print("The Left 4 of " + Eric + ": " + Eric.substring(0,4));
</pre>
</pre>


Line 45: Line 35:


[[Category:Strings]]
[[Category:Strings]]
[[Category:BASIC Functions]]

Latest revision as of 15:29, 25 March 2019

This function is for BASIC compatibility. It is not available in pure JavaScript projects.

Left(string, length)

Description

Left returns a string containing a specified number of characters from the left end of a string. The required parameter, string, is any valid string expression. The required parameter, length, is any valid numeric expression. If length is 0, an empty string ("") is returned. If length is greater than the size of string, the entire string is returned.

Example (Basic)

Rem Left Example
'Left returns substring from string left end
Dim Wendy, Eric
Wendy = "Testaburger"
Eric = "Cartman"
Print "The Left 4 of " & Wendy & ": " _
  & Left(Wendy, 4)
Print "The Left 4 of " & Eric & ": " _
  & Left(Eric, 4)

Output

The Left 4 of Testaburger: Test
The Left 4 of Cartman: Cart

Related Items

Len, Mid, Right