Len: Difference between revisions
Jump to navigation
Jump to search
Add javascript snippet |
|||
Line 5: | Line 5: | ||
Len returns a long value specifying the number of characters in a string, or the number of bytes required to output a variable. The optional parameter, ''string'', is any valid string expression. The optional parameter, ''variable'', is any variable, if variable contains a string the length of the string is returned. One (and only one) of the optional parameters, ''string'' and ''variable'', must be supplied. | Len returns a long value specifying the number of characters in a string, or the number of bytes required to output a variable. The optional parameter, ''string'', is any valid string expression. The optional parameter, ''variable'', is any variable, if variable contains a string the length of the string is returned. One (and only one) of the optional parameters, ''string'' and ''variable'', must be supplied. | ||
== Example == | == Example (Basic) == | ||
<pre> | <pre> | ||
Line 16: | Line 16: | ||
Print "LenB of Frog:", LenB(Frog) | Print "LenB of Frog:", LenB(Frog) | ||
Print "Len of Survived:", Len(Survived) | Print "Len of Survived:", Len(Survived) | ||
</pre> | |||
== Example (JavaScript) == | |||
<pre> | |||
// Len Example | |||
/* Len returns string length or variable size */ | |||
var Frog, Survived; | |||
Frog = "Staring"; | |||
Survived = 2; | |||
NSB.Print("Len of Frog:" + " " + Frog.length); | |||
NSB.Print("LenB of Frog:" + " " + Frog.length); | |||
NSB.Print("Len of Survived:" + " " + Survived.toString().length); | |||
</pre> | </pre> | ||
Revision as of 20:39, 19 May 2013
Len(string | variable)
Description
Len returns a long value specifying the number of characters in a string, or the number of bytes required to output a variable. The optional parameter, string, is any valid string expression. The optional parameter, variable, is any variable, if variable contains a string the length of the string is returned. One (and only one) of the optional parameters, string and variable, must be supplied.
Example (Basic)
Rem Len Example 'Len returns string length or variable size Dim Frog, Survived Frog = "Staring" Survived = 2 Print "Len of Frog:", Len(Frog) Print "LenB of Frog:", LenB(Frog) Print "Len of Survived:", Len(Survived)
Example (JavaScript)
// Len Example /* Len returns string length or variable size */ var Frog, Survived; Frog = "Staring"; Survived = 2; NSB.Print("Len of Frog:" + " " + Frog.length); NSB.Print("LenB of Frog:" + " " + Frog.length); NSB.Print("Len of Survived:" + " " + Survived.toString().length);
Output
Len of Frog: 7 LenB of Frog: 7 Len of Survived: 1