Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.6j

Application v 6.5c

  

 

Chapter FiveGeneral Functions (continued)

CompareStrings Function

Overview

The CompareStrings function compares the value of the characters between two strings and returns a result as less than, equal to, or greater than. Options allow the only the beginning or end of the string to matched.

Syntax/Parameters

Syntax

int = CompareStrings ( string a, string b, [dword options] );

Parameters

a

A string to compare.

b

A string to compare.

options

An optional dword containing option bits. If omitted, a simple case sensitive compare is performed.

Return Value

Returns an int value as:

-1if a < b
0if a == b
1if a > b

Remarks

The CompareStrings function combines the basic comparison operators (==, <, and >) to allow string comparison in a single operation. In addition, the options parameter allows the following modes and options:

CS_COMPARE        Simple compare, default
CS_BEGINS_WITH    Begins with parameter a (as a string prefix)
CS_ENDS_WITH      Ends with a (as string suffix)

CS_LOOSE          An option to allow the short of a or b is as the prefix or suffix
CS_NO_CASE        An option to compare strings without regard to case

By default (no options, 0x000000000 or CS_COMPARE), the function compares a and b on a character-by-character basis. If all characters matchup between the strings up to the matching terminating /0 character, the return result is 0. If any character mismatches, the comparison is stopped and -1 or 1 is returned depending on whether the character in a is less than the character at the same position in b.

The CS_NO_CASE option forces the function to ignore upper/lower case differences (same as the CompareStringsNoCase function in simple mode).

In begins with or ends with mode, only a portion of the string is checked. With the CS_BEGINS_WITH mode set, the length of the a parameter sets the size of the compare region. If CS_LOOSE is added in, the shorter of a or b becomes the prefix. Alternatively, with the CS_ENDS_WITH mode set, the length of the a parameter sets the size of the compare region. If CS_LOOSE is added in, the shorter of a or b becomes the suffix.

When in case sensitive mode, except for the terminating zero (as is the case with string types), the CompareString function essentially performs a binary, character-for-character comparison.

 Related Functions

Platform Support

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

Legato IDE, Legato Basic

Page revised 2026-07-20