value IN value_set
value | The value to find in the value_set. This is usually a single value, but if the value_set is a DICTIONARY with a multiple-component key, this may also be a ROW. |
value_set | A set of values. This may be a set expression, the SET function, or a DICTIONARY. |
The IN operator is shorthand for a collection of OR conditions. It is an operator that will search a set to find an inclusion, resulting in a Boolean return. Using IN is much more efficient than the equivalent OR expression.
Example:
ABCset := ['A', 'B', 'C']; IsABCStatus := Person.Status IN ABCset; //This code is directly equivalent to: // IsABCStatus := Person.Status = 'A' OR // Person.Status = 'B' OR // Person.Status = 'C'; IsABC(STRING1 char) := char IN ABCset; Trades_ABCstat := Trades(IsABC(rate)); // Trades_ABCstat is a record set definition of all those // trades with a trade status of A, B, or C //SET function examples r := {STRING1 Letter}; SomeFile := DATASET([{'A'},{'B'},{'C'},{'D'},{'E'}, {'F'},{'G'},{'H'},{'I'},{'J'}],r); x := SET(SomeFile(Letter > 'C'),Letter); y := 'A' IN x; //results in FALSE z := 'D' IN x; //results in TRUE //DICTIONARY examples: rec := {STRING color,UNSIGNED1 code}; ColorCodes := DATASET([{'Black' ,0 }, {'Brown' ,1 }, {'Red' ,2 }, {'White' ,3 }], rec); CodeColorDCT := DICTIONARY(ColorCodes,{Code => Color}); OUTPUT(6 IN CodeColorDCT); //false ColorCodesDCT := DICTIONARY(ColorCodes,{Color,Code}); OUTPUT(ROW({'Red',2},rec) IN ColorCodesDCT);
See Also: Basic Definition Types, Definition Types (Set Definitions), Logical Operators, PATTERN, DICTIONARY, ROW, SET, Sets and Filters, SET OF, Set Operators