Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter FiveGeneral Functions (continued)

FindInString Function

Overview

The FindInString function scans a string for a target string and returns its position. The function has options to begin its search from a specific location, specify case sensitivity or to search in look back mode.

Syntax/Parameters

Syntax

int = FindInString ( string source, string match, [int position, [dword flags]] );

int = FindInString ( wstring source, wstring match, [int position, [dword flags]] );

Parameters

source

A string or wstring to search.

match

A string or wstring to find within the source. The match parameter must match the source parameter type.

position

An optional int containing a zero-based starting position. By default, the search begins at the start of the string (position = 0).

flags

An optional dword to specify options:

TRUE  = case-sensitive

FALSE = case-insensitive

By default, the search is case-insensitive. See remarks for additional flags.

Return Value

Returns an int containing the zero-based starting position within source where match was found or -1 on an error. Use the GetLastError function to retrieve error information.

Remarks

Unlike the InString function, the FindInString functions offers greater control over the search mechanics. Specifically, it permits a starting search position and case-sensitivity to be specified. However, this function does not allow searching for a specific character, which makes it a less ideal tool for finding white space, word space, or other special characters within a string. A boolean version of this function is available as the IsInString function.

If match is not found within source, the GetLastError function will return ERROR_EOD. If the position is outside the length of source, the GetLastError function will return ERROR_RANGE.

The flags parameter specifies two options:

FIS_NOT_CASE_SENSITIVE  0x00000000   Find without Case Sensitivity, same as FALSE, default

FIS_CASE_SENSITIVE      0x00000001   Find with Case Sensitivity

FIS_LOOK_BACK           0x00010000   Scan Backwards (reverse)

Case-insensitive matching is performed on a locale basis as set by Windows. For US, on ASCII matching is the only case matching performed.

Related Functions

Platform Support

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

Legato IDE, Legato Basic