Name:
lookdown
Syntax:

LOOKDOWN target,(value0,value1...valueN),variable

Target - is a variable/constant which will be compared to Values.

Values - are variables/constants.

Variable - receives the result (if any).

Description:

Get target's match number (0-N) into variable (if match found).

The lookdown command should be used when you have a specific value to compare with a pre-known list of options. The target variable is compared to the values in the bracket. If it matches the 5th item the number '4' is returned in variable. Note the values are numbered from 0 upwards (not 1 upwards). If there is no match the value of variable is left unchanged.

Applies To:
All
See Also:
Related Create:
    Share:
    Print:

    Determine data position

    In this example the variable b2 will contain the value 3 if b1 contains "d" and the value 4 if b1 contains "e"

    Code Example:
    	lookdown b1,("abcde"),b2
    Copy Code Submit an Example

    Find the highest value

    This program will find the variable which holds the highest value. This is done in two steps; determining what the highest value is by using 'min' operators and a second seto of using 'lookdown' to find which variable holds that value.

    Code Example:
    symbol maxval   = b10
    symbol varindex = b11
    
    ; Put some numbers into b0 to b2
    
    b0 = 5
    b1 = 10
    b2 = 7
    
    ; Find the highest value
    maxval = b0 min b1 min b2
    
    ; Find the variable holding that value
    lookdown maxval, ( b0, b1, b2 ), varindex
    
    ; varindex has value 0 when variable b0 holds the largest value, value 1 when b1 does, and 
    ; value 2 when b2 does.
     
    sertxd( "The largest value was ", #maxval, " which is held in variable b", #varindex, cr, lf )
    
    Copy Code Submit an Example

    Submit Your Own Code!

    You must be logged in to submit code examples. Login now.