TAKE Function

── TAKE ── ( ──<string expression>── , ──<arithmetic expression>── ) ──┤

The TAKE function returns a string whose value is equal to the first <arithmetic expression> characters taken from the value of the string expression. The value of the arithmetic expression is rounded to an integer, if necessary. An error occurs if the rounded value of the arithmetic expression is greater than the number of characters in the string expression or less than 0 (zero). If the rounded value of the arithmetic expression is 0, the result is the null string. If the rounded value of the arithmetic expression is equal to the length of the string expression, the result is the same as the value of the string expression.

The TAKE function and the DROP function are complementary functions. This means that for any string expression S and any arithmetic expression A in the range 0 <= A <= LENGTH(S), the following relation is always true:

S = TAKE(S,A) CAT DROP(S,A)

For additional information, see DROP Function.

Examples of TAKE Function

In the following examples, string S has a length of 6 and contains 8"ABCDEF".

TAKE(S,2) = 8"AB"

TAKE(S,4) = 8"ABCD"

TAKE(DROP(S,2),2) = 8"CD"