CHOICE
                                  ======


                  Select one of a list of parameters


Usage
-----


CHOICE: Given a list of items, return the specified item:

        result = CHOICE(choice_number%, first, second, third, .., error)

Where result is the choice_number% item in parameter list.

If choice_number% is outside the possible range (1..N) the last item, N, is
returned irrespective.

first, second, etc can be of any scalar type, and that is the type of the
item returned.


In Use
------

Each parameter is fetched according to its type and the same type is
returned.

Just note that although CHOICE is type-agnostic, the normal rules of
coercion apply to the receiving variable:

        direction$ = CHOICE(direction%, 'Left', 'Up', 'Right', 'Down', 'Nowhere')
or
        number = CHOICE(n%, SQRT(xyz), MyFunction(abc), x%, b%, 'Error')

The latter example will fail if n% < 0 or n% > 4, because 'Error' is not
numeric. The rest should work though.

Another thing to note is that S*BASIC evaluates ALL the parameters,
although only the required one is fetched onto the stack. So any action
of MyFunction, for example, will be carried out whatever the value of n%.


Software Status
---------------

V0.01, pjw, < 1994
V0.02, pjw, 2005 Mar 05, extracted from PTOOL

               Conditions of use and DISCLAIMER as per Knoware.no