[Overview][Constants][Types][Procedures and functions][Index] Reference for unit 'LazStringUtils' (#lazutils)

StringCase

Emulates the CASE .. OF statement for string values.

Declaration

Source position: lazstringutils.pas line 103

function StringCase(

  const AString: string;

  const ACase: array of string

):Integer; overload;

function StringCase(

  const AString: string;

  const ACase: array of string;

  const AIgnoreCase: Boolean;

  const APartial: Boolean

):Integer; overload;

Arguments

AString

  

Value compared to the array elements.

ACase

  

Determines the selector in the return value

Function result

Ordinal position for the case selector, or -1 when a match is not found.

Arguments

AString

  

Value compared to the array elements.

ACase

  

Determines the selector in the return value

APartial

  

True is a partial match at the start of the selector is a match.

Description

StringCase is an overloaded Integer function used to emulate the Pascal CASE .. OF statement.

AString contains the value compared to the elements in the ACase array.

ACase is an array of String values which determine the result for the function.

AIgnoreCase indicates whether case is significant when comparing AString to elements in ACase. False indicates that case is not used in the comparison.

APartial indicates whether the value in AString can be a partial match for the value in an array element. When set to False, AString must match the array element exactly to be considered a match. When set to True, any value in ACase which starts with the value in AString is considered a match.

The return value contains the ordinal position of the element in ACase which matches the value in AString. The return value is -1 if no match was found for the value in AString.