switchmatchexact(
switchmatchexact(
KEY
,
CASE
,
VALUE
,
...
,
DEFAULT
)

The switchmatchexact( function chooses from a list of values based on a wildcard match.

Parameters

This function has four required parameters:

key – The value that controls which option is selected.

case – The wildcard value that must match the key value to select this option. This may contain the `*` and `?` wildcard characters, see the match operator to learn more about wildcards.

value – The value associated with this case.

… – One or more additional case/value pairs may be inserted here

default – The default value that will be used if the key does not match any of the cases.

Description

The switchmatchexact( function makes it easy to choose from a list of values. The first parameter is the key. The function attempts to match the key value with each of the case values (from left to right). Each match can include the `*` and `?` wildcard characters. If it finds a match, the function returns the corresponding value. If there are no matches at all, the default value is returned. (Each case/value pair is shown on a separate line in the examples below, but this is not necessary.)

In the examples below, the result is returned based on just the first character, or the first two characters.

    switchmatchexact("Gold",
        "G*",79,
        "S*",47,
        "C*",29,
        "T*",50,
         0) ☞ 79
    switchmatchexact("Copper",
        "G*",79,
        "S*",47,
        "C*",29,
        "T*",50,
         0) ☞ 29
    switchmatchexact("Carbon",
        "G*",79,
        "S*",47,
        "Ca*",6,
        "Co*",29,
        "T",50,
         0) ☞ 6
    switchmatchexact("Helium",
        "T*",79,
        "S*",47,
        "C*",29,
        "T*",50,
         0) ☞ 0

Note: The switchmatchexact( function is case sensitive. Use the switchmatch( function if you need case insensitivity.

See Also

- ?( -- allows a formula to make a true/false, yes/no decision.
- and -- returns true if both operands are true.
- between( -- checks to see if a value is between two other values.
- boolstr( -- converts a Boolean value to text, either `"true"` or `"false"`.
- false( -- returns false.
- limit( -- checks to see if a value is between a minimum and maximum value. If it is, the value is returned unchanged. If it is below the minimum, the minimum value is returned. If it is above the maximum the maximum value is returned.
- not -- reverses a boolean value.
- not( -- reverses a Boolean value
- notbetween( -- checks to see if a value is *not* between two other values.
- or -- returns true if either operand is true, or false if both are false.
- switch( -- chooses from a list of values.
- true( -- returns true.
- xor -- returns true if one of the two parameters is true, false if neither or both are true.

History

Version | Status | Notes
10.0 | New | New in this version.