LeftValues()
Category: Text
Syntax: LeftValues ( text; numberOfValues ) |
Parameters:
textA return-delimited text string or expression that returns a return-delimited text string.
numberOfValuesAny positive number or expression that returns a positive number.
Data type returned: Text
Description:
Returns the specified number of items from the beginning of the text parameter.
The LeftValues() function returns the first n items from a return-delimited array, where n is the number specified in the text parameter. The items will themselves be a return-delimited array, and there will always be a trailing return at the end of the last item.
You can remove the trailing return in a number of ways. If you are extracting a single item from the beginning of a list, you can use the Substitute() function to remove any return charactersfor instance, Substitute (LeftValues (text; 1); "¶"; ""). You would not use this method when returning multiple items because the internal delimiters would be lost as well. Instead, the following function returns everything except the last character of the extracted list:
Let (x = LeftValues (text; n); Left (x; Length (x) - 1 ))
Another option is the following:
LeftWords (LeftValues (text; n); 999999)
This function takes advantage of the fact that the LeftWords() function ignores any leading or trailing delimiters. Be aware that this function also ignores leading or trailing delimiters (including punctuation symbols) from the actual items in the array, so in some cases this function does not return the desired result. The safest function to use in all cases is the Let() function (described ahead).
Examples:
Function | Results |
---|---|
LeftValues("A¶B¶C¶D¶E";3) | Returns the following list: |
A | |
B | |
C | |
LeftValues (WindowNames;1) | Returns the name of the active window. |
Категории