MiddleValues()

Category: Text

Syntax: MiddleValues ( text; startingValue; numberOfValues )

Parameters:

textAny return-delimited string or expression that generates a return-delimited string.

startingValueAny positive integer or expression that returns a positive integer.

numberOfValuesAny positive number or expression that returns a positive integer.

Data type returned: Text

Description:

Returns the specified number of items from the middle of the text parameter, starting at the value specified in the startingValue parameter.

The MiddleValues() function returns a slice from the middle of a return-delimited array. The output itself will be a return-delimited array, and there will always be a trailing return at the end of the last item.

See the LeftValues() function for a discussion of methods to remove the trailing return from the output of the MiddleValues() function.

The MiddleValues() function is used frequently in scripts to loop over the items in an array. Each time through the loop, you can extract the next value from the array by incrementing a counter. For instance:

Set Variable [ $counter; 1 ] Loop Set Variable [$value; MiddleValues ( $myArray; $counter; 1 ) { ... some set of operations involving the extracted item } Exit Loop If [$counter = ValueCount ( $myArray )] End Loop

Examples:

Function

Results

MiddleValues ("A¶B¶C¶D¶E"; 2; 3)

Returns the following:

 

B

 

C

 

D

MiddleValues (test; 3; 1)

Returns the following:

 

C

 

When test contains:

 

A

 

B

 

C

 

D

Категории