Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter EightData Functions (continued)

FindInList Function

Overview

The FindInList function linearly scans a single-dimension array and attempts to match an entry based on specified metrics.

Syntax/Parameters

Syntax

int = FindInList ( string array[], string pattern, [int mode], [int start] );

int = FindInList ( int array[], long data, [int start] );

Parameters

array

An array of string or int type data which must resolve to a single dimension. The integer type data can be up to 64 bits in width.

pattern

A string to search for within a string list (array). The array parameter must be a string type.

data

An int value to search for within the list (array). The array parameter must resolve to an integer type. Either parameter can be up to 64 bits.

mode

An optional int specifying a match mode as defined below. The default is FIND_EXACT, which searches for an exact case-sensitive match. The mode codes are as follows:

  Term   Ordinal   Description  
  FIND_EXACT   0   Match Exactly  
  FIND_NO_CASE   1   Not Case-Sensitive  
  FIND_WILD_CARD   2   Use Wild Card Matching  
  FIND_WILD_CARD_NO_CASE   3   Use Wild Card Matching, No Case  
  FIND_PARTIAL   4   Match Loosely/Partially  
  FIND_PARTIAL_NO_CASE   5   Match Loosely/Partially, No Case  

This parameter may only be used with string searches. Use caution when using integer mode to not confuse the mode and start parameters since they are the same type. Do not use this parameter with integer data types.

start

An optional zero-based int specifying the starting search position.

Return Value

Returns an int specifying the matching index position or -1 if the item is not found. Use the GetLastError function to retrieve error information.

Remarks

The search range is from the optional specified starting position to the last element. Data from the last element to the allocated end of the array are not searched.

Since the return index can be -1 on error, it is imperative to check for an error prior to referencing the array with the returned value. The GetLastError function will return the error code ERROR_EOD if the item is not found.

For string searches, the FIND_PARTIAL and FIND_PARTIAL_NO_CASE modes look for the pattern inside the string entry. If it matches, the items is considered found.

For integer searches, use caution mixing types and signs since the compare is performed at a 64-bit level and negative items may not sign extend unless types match exactly.

Important: The mode parameter cannot be used with integer searches. Programmers should exercise care not to add a mode parameter which could be mistaken for the start parameter, thus resulting in unpredictable behavior.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic

Page revised 2024-12-13