Mid: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
JwellsNB (talk | contribs)
Add javascript snippet
Line 5: Line 5:
Mid returns a string containing characters from the middle of a string. The required parameter, ''string'', is any valid string expression. The required parameter, ''start'', is any valid numeric expression, if start is greater than the length of string, a zero-length string is returned (""). The optional parameter, ''length'', is any valid numeric expression and it specifies the number of characters to return. If length is not used, or exceeds the number of remaining characters in string, all characters from start to the end of string are returned.
Mid returns a string containing characters from the middle of a string. The required parameter, ''string'', is any valid string expression. The required parameter, ''start'', is any valid numeric expression, if start is greater than the length of string, a zero-length string is returned (""). The optional parameter, ''length'', is any valid numeric expression and it specifies the number of characters to return. If length is not used, or exceeds the number of remaining characters in string, all characters from start to the end of string are returned.


== Example ==
== Example (Basic) ==


<pre>
<pre>
Line 15: Line 15:
Mister = "Hankey"
Mister = "Hankey"
Print "From Hankey:", Mid(Mister, 4)
Print "From Hankey:", Mid(Mister, 4)
</pre>
== Example (JavaScript) ==
<pre>
// Mid Example
/* Substring returns characters from string middle */
var Eric, Mister;
Eric = "Cartman";
NSB.Print("From Cartman: " + Eric.substring(1,4));
Mister = "Hankey";
NSB.Print("From Hankey: " + Mister.substring(3));
</pre>
</pre>



Revision as of 22:00, 19 May 2013

Mid(string, start[, length])

Description

Mid returns a string containing characters from the middle of a string. The required parameter, string, is any valid string expression. The required parameter, start, is any valid numeric expression, if start is greater than the length of string, a zero-length string is returned (""). The optional parameter, length, is any valid numeric expression and it specifies the number of characters to return. If length is not used, or exceeds the number of remaining characters in string, all characters from start to the end of string are returned.

Example (Basic)

Rem Mid Example
'Mid returns substring from string middle
Dim Eric, Mister
Eric = "Cartman"
Print "From Cartman:", Mid(Eric, 2, 3)
Mister = "Hankey"
Print "From Hankey:", Mid(Mister, 4)

Example (JavaScript)

// Mid Example
/* Substring returns characters from string middle */

var Eric, Mister;
Eric = "Cartman";
NSB.Print("From Cartman: " + Eric.substring(1,4));
Mister = "Hankey";
NSB.Print("From Hankey: " + Mister.substring(3));

Output

From Cartman: art
From Hankey:  key

Related Items

Left, Right