Choose Function

Purpose

Selects and returns a value from a list of arguments.

Syntax

Choose(index, choice-1[, choice-2, ... [, choice-n]])

Description

Choose returns a value from the list of choices based on the value of index. If index is 1, Choose returns the first choice in the list; if index is 2, it returns the second choice, and so on.

You can use Choose to look up a value in a list of possibilities. For example, if index evaluates to 3 and choice-1 = "one", choice-2 = "two", and choice-3 = "three", Choose returns "three". This capability is particularly useful if index represents the value in an option group.

Choose evaluates only the choice of the given index!

The Choose function returns a Null if index is less than 1 or greater than the number of choices listed.

If index is not a whole number, it is rounded to the nearest whole number before being evaluated.

Example

Local Byte ch, n

For n = 1 To 3

Print "When ch = "; n; ", "; Choose(n, "First", "Second", "Third"); " will be printed."

Next n

Remarks

The VB function Choose evaluates every choice, GFA-BASIC 32 only the specified one.

See Also

Iif

{Created by Sjouke Hamstra; Last updated: 25/09/2014 by James Gaite}