Start and length parameters in string operations

Last Updated : Sep 08, 2012 |

The start and length parameters defined for vector variables are both applied only when the resulting set command string operation value is assigned to a vector variable using the following rules:

  • The start and length definition for the assigned variable specifies the portion of the resulting set command operation digit string that is selected for the assignment.

  • The start definition for the assigned variable is always used to select the portion of the result string to use in the assignment. If start is defined as 1, the portion selected includes all of the left-side digits. For example, if variable S has start = 1, and the result string is 123..., the assignment to S is 123 ... When the start position is greater than 1, the left-side digits before the start position are deleted. For example, if S = 2 and the result string is 123..., the assignment to S is 23...

  • The resulting string after application of the variable start position definition must be equal to or less than the length definition. If the string length is greater than the length definition for the variable, the right-side digits are deleted so that the total string length is equal to the length definition. For example, if the definition for variable S is start = 2, length = 5 and the result of the string operation is 1234567, the assignment to variable S is 23456.

  • If the resulting string is shorter than the length definition, the string will not have leading zeros added to match the variable length definition.

Note:

For an assignment to the digits buffer, the start position is always defined as 1 and the length is always defined as 16 digits. These rules are applied for assignment to the digits buffer in the same manner as assignment to a vector variable using start = 1 and length = 16.