Help Center
Help CenterFreeBASIC

Rightfunction

Returns the rightmost substring of a string

String Functionsfunctiondocumented

Syntax

Declare Function Right ( ByRef str As Const String, ByVal n As Integer ) As String
Declare Function Right ( ByRef str As Const WString, ByVal n As Integer ) As WString

Parameters

NameDescription
strThe source string.
nThe substring length, in characters.

Return value


Returns the rightmost substring from str.

Description


Returns the rightmost n characters starting from the right (end) 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.

Remarks

Usage


result = Right[$]( str, n )

Platform Differences


  • DOS does not support the wide-character string version of Right.

Dialect Differences


  • The string type suffix "$" is required in the -lang qb dialect.
  • The string type suffix "$" is optional in the -lang fblite dialect.
  • The string type suffix "$" is ignored in the -lang fb dialect, warn only with the -w suffix compile option (or -w pedantic compile option).

Differences from QB


  • QB does not support Unicode.

See also


Example


Dim text As String = "hello world"

Print Right(text, 5)

will produce the output:

world
An Unicode example:
 
dim text as wstring*20
text = "Привет, мир!"
print right(text, 5) 'displays " мир!"

Reference

  • Documented in KeyPgRight.html