RealTest User Guide
RealTest User Guide

 

 

Navigation: Realtest Script Language > Syntax Element Details >

Select

 

 

 

 

Category

General-Purpose Functions

Description

Conditional choice function

Syntax

Select(condition, if_true, condition, if_true, ...)

Parameters

condition - formula specifying a true/false condition (non-zero means true)

if_true - formula to evaluate and return the result of if condition is true

Notes

Select is similar to IF in that it provides a kind of conditional branch function.

In fact, the following two statements are equivalent:

if(cond1, value1, value2)

select(cond1, value1, 1, value2)

The purpose of select becomes more apparent when multiple if statements need to be nested:

if(cond1, if(cond2, if(cond3, value3, NaN), value2), value1)

select(cond1, value1, cond2, value2, cond3, value3)

In this example, the select expression is clearly simpler.

If select finds no conditions that return non-zero ("true"), then the function returns NaN. This is different from if, which will never return NaN unless done explicitly as in the above example.

To make select always return a default value if no conditions match (as in the first select example above), either make the final condition simply "1" (or any non-zero value), or use an odd number of arguments:

select(cond1, value1, value2)

When an odd number of arguments is used, the last argument becomes the default value.

 

 

 

Copyright © 2020-2024 Systematic Solutions, LLC