iIn( ** val, ** array[] ) return boolean - Syntax 1

** = all data types

This function is used to check if a value is present or not in a specified array of values of the same type.

It allow to replace usual codes like:

boolean lb_found
integer li_i
integer li_size
string ls_colors[]
...
ls_colors = {'RED','ORANGE','GREEN'}
...
li_size = upperBound( ls_colors )
for li_i = 1 to li_limit
if as_color = ls_colors[li_i] then
lb_found = true
exit
end if
next
if lb_found = false then return -1
...

by a more concise one:

string ls_colors[]
...
ls_colors ={ 'RED','ORANGE','GREEN' }
...
if not #.iIn( as_color, ls_colors ) then return -1
...

Upgrade for releases from 03/07/2015

You can now use the new property iInFoundPos that hold the index of the retrieved value searched since the last call of method iIn. See example below:

 string ls_colors[]
...
ls_colors ={ 'RED','ORANGE','GREEN' }
...
// Replace GREEN by BLUE, and ORANGE by GREEN
if #.iIn( "GREEN', ls_colors ) = true then ls_colors[ #.iInFoundPos ] = "BLUE"
if #.iIn( "ORANGE', ls_colors ) = true then ls_colors[ #.iInFoundPos ] = "GREEN"
..


See Also
iIn - Syntax 2
iInFoundPos

Last edited Jul 3, 2015 at 10:40 AM by domangep, version 7