Right Command
Obsolete
This command is replaced by the Right function.
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
lengthis less than 1,rightwill output no characters. - If
lengthis greater than the length ofstring,rightwill output all ofstring. - Although
rightcan be used on Date, Integer, and Number type variables, it is typically used on String type variables. stringandvariablemay be the same variable. Used this way,rightsimply truncatesstringon the left:
right suffix to suffix 2
In this example, the rightmost 2 characters are removed from the value of the variable suffix.