-->
Visual RPG Language Reference  

%LOOKUP Function (Look Up an Array Element)

%LOOKUP built-in function returns the array index of the item in Array that matches the Argument; otherwise, negative one is returned if no match is found.

%LOOKUP   (Argument, Array{, Start-index {, Num-elements}})
%LOOKUPLT (Argument, Array{, Start-index {, Num-elements}})
%LOOKUPGE (Argument, Array{, Start-index {, Num-elements}})
%LOOKUPGT (Argument, Array{, Start-index {, Num-elements}})
%LOOKUPLE (Argument, Array{, Start-index {, Num-elements}})

Parts

Argument, Array

Required.  Contains the search argument and the name of the array to be searched.  Both must be the same type but do not need to be the same length.

Start-index, Num-elements

Optional.  Non-float numerics with zero decimal positions, containing the index in which to begin the search, and the number of elements to be searched.  By default, the entire Array is searched.

Example

If no match is found, -1 is returned.  Unlike green-screen RPG's one-based %LOOKUP, AVR's %LOOKUP is zero-based. 

Remarks

If no match is found, -1 is returned.  Unlike green-screen RPG's one-based %LOOKUP, AVR's %LOOKUP is zero-based. 

The search starts at index Start-index and continues for Num-elements.  The function returns the array index of the item in Array that matches Argument as follows:

Unlike the LOOKUP op code, %LOOKUP only applies to arrays.  To look up a value in a table, use the %TLOOKUP function.

Note:  %FOUND and %EQUAL are NOT set following a %LOOKUP operation.

 

See Also

Built-in Function Overview
DCLARRAY
DclAliasGroup
DCLDSFLD
LOOKUP
%EQUAL
%FOUND
%TLOOKUP