Skip to content

Left Command

Obsolete

This command is replaced by the Left function.

See Also

Purpose

To move the leftmost characters of a value to a variable.

Syntax

left
value
to
variable [length]

What It Does

The left command moves the number (counted from the left) of characters from value given in length to variable. The value of length is moved to the predefined variable strmark.

string state_abbreviation
move "CALIFORNIA" to state
left state to state_abbreviation 2

In this example, the left command places the first two characters (CA) into the string variable state_abbreviation.

If length is omitted from the command, the value of the predefined variable strmark is used for the function. strmark is set by the insert, mid, pad, pos, replace, and sysdate commands.

string name
string last_name
move "Schweitzer, Albert" to name
pos "," in name
left name to last_name

In this example, the pos command determines the position (11) of the comma in the string variable name. The left command, lacking a length argument, uses this value to extract "Schweitzer," (including the comma) to move to the string variable last_name.

Notes

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

In this example, all characters after the second (counted from the left) are removed from the value of the variable state_name.