Skip to content

Right Command

Obsolete

This command is replaced by the Right function.

See Also

Purpose

To move the rightmost characters of a variable to another variable.

Syntax

right string to variable [length]

What It Does

The right command moves the specified number of characters (counted from the right) from the string given in length to variable.

string team score
move "MIAMI DOLPHINS 34" to team
right team to score 2

In this example, the rightmost two characters of the contents of the string variable team (34) are moved to the string variable score.

The length may be given in the command as a variable, or it may be omitted. In the latter case, the value of the predefined variable strlen will be used. strlen is output by pos and other string processing commands.

string team score
move "MIAMI DOLPHINS 43" to team
pos " " in team
right team to score
while strmark gt 0
    right score to score (strlen - 1)
    pos " " in score
end

In this example, the portion of the value of the string variable team beginning with the first space is moved to the variable score. The first pos command above detects the position of the leftmost space in team and moves it implicitly to the predefined variable strmark. If a space is found (strmark gt 0), the while ... end loop is executed, truncating the portion of score to the left of the leftmost space until there are no spaces left in score. In the example above, score would contain 43 when the loop stopped executing.

Notes

  • If length is less than 1, right will output no characters.
  • If length is greater than the length of string, right will output all of string.
  • Although right can be used on Date, Integer, and Number type variables, it is typically used on String type variables.
  • string and variable may be the same variable. Used this way, right simply truncates string on the left:
right suffix to suffix 2

In this example, the rightmost 2 characters are removed from the value of the variable suffix.