4D v16.3Choose |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
Choose
Choose
The Choose command returns one of the values passed in the value1, value2, etc. parameters depending on the value of the criterion parameter. You can pass either a Boolean or Number type in the criterion parameter:
The command accepts all types of data for the value parameter(s), except for pictures, pointers, BLOBS and arrays. Nevertheless, you need to make sure that all the values passed are of the same type, 4D will not carry out any verification on this point. If no value corresponds to criterion, Choose returns a “null” value with respect to the type of the value parameter (for example, 0 for a Number type, “” for a String type, and so on). This command can be used to generate concise code that replaces tests of the “Case of” type that take up several lines (see example 2). It is also very useful in places where formulas can be executed: query editor, application of a formula, quick report editor, column calculated in a listbox, and so on. Here is an example of the typical use of this command with a Boolean type criterion: vTitle:=Choose([Person]Masculine;"Mr";"Ms") This code is strictly equivalent to: If([Person]Masculine) Here is an example of the typical use of this command with a Number type criterion: vStatus:=Choose([Person]Status;"Single";"Married";"Widowed";"Divorced") This code is strictly equivalent to: Case of
|
PROPERTIES
Product: 4D HISTORY
Created: 4D v11 SQL ARTICLE USAGE
4D Language Reference ( 4D v16) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||