Right: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
(Add javascript snippet)
Line 5: Line 5:
Right returns a string containing a number of characters from the right 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.
Right returns a string containing a number of characters from the right 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 ==
== Example (Basic) ==


<pre>
<pre>
Line 17: Line 17:
Print "The Right 4 of " & Eric & ":", _
Print "The Right 4 of " & Eric & ":", _
   Right(Eric, 4)
   Right(Eric, 4)
</pre>
== Example (JavaScript) ==
<pre>
// Right Example
/* Substring is used to return characters from string right end */
var Wendy, Eric;
Wendy = "Testaburger";
Eric = "Cartman";
NSB.Print("The Right 6 of " + Wendy + ": " + Wendy.substring(Wendy.length-6,6) + "<br>");
NSB.Print("The Right 6 of " + Eric + ": " + Eric.substring(Eric.length-6,6) + "<br>");
</pre>
</pre>



Revision as of 21:04, 19 May 2013

Right(string, length)

Description

Right returns a string containing a number of characters from the right 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 Right Example
'Right returns sub string from string right end
Dim Wendy, Eric
Wendy = "Testaburger"
Eric = "Cartman"
Print "The Right 6 of " & Wendy & ":", _
  Right(Wendy, 6)
Print "The Right 4 of " & Eric & ":", _
  Right(Eric, 4)

Example (JavaScript)

// Right Example
/* Substring is used to return characters from string right end */

var Wendy, Eric;
Wendy = "Testaburger";
Eric = "Cartman";
NSB.Print("The Right 6 of " + Wendy + ": " + Wendy.substring(Wendy.length-6,6) + "<br>");
NSB.Print("The Right 6 of " + Eric + ": " + Eric.substring(Eric.length-6,6) + "<br>");

Output

The Right 6 of Testaburger:burger
The Right 4 of Cartman:    tman

Related Items

Left, Mid