Like

Top  Previous  Next

S

A

W

WS

ü

ü

Syntax -

       If <literal string> LIKE <pattern string> …

Where:

<literal string> is a literal string or a variable containing a literal string.

<pattern string> is a literal string or a variable containing a literal string.

Description:

This comparison operator is used to determine if a specified pattern exists within a literal string or a variable containing a literal string.  This comparison returns a TRUE condition if the first string contains the pattern specified by the second string.  A TRUE condition will cause EMUE to process the valid statement defined by <valid script statement>.

This comparison operator can be used with either an in-line If (the original OLIE™ syntax) or a Block If.

 

Notes: If both strings are empty strings, the result of the comparison is TRUE.

       If one of the two strings is an empty string and the other is not empty, the result of the comparison is FALSE.  

Both values are treated as strings, even if one or both of the strings are numeric.

       This comparison operator is not case sensitive.

 

The LIKE comparison can be used to match strings using wildcard characters, character lists, or character ranges, in any combination.

The following table identifies the characters that can be used in specifying the pattern to be used in the comparison and how they will be used when the comparison is made.

 

Characters in Pattern

Matches in string

?

Any single character

*

Zero or more characters

#

Any single digit (0–9)

[charlist]

Any single character in charlist

[!charlist]

Any single character not in charlist

 

Where charlist is a list of one or more characters, enclosed in brackets ([ ]). This list can include almost any character code, including digits, and it is used to compare a single character in the <literal string> to the members of the list.

 

To use the special characters left bracket ([), question mark (?), number sign (#), and asterisk (*), in a <pattern string> they must be a member of a charlist enclosed in brackets.
The right bracket (]) cannot be used within a [charlist], but it can be used as an individual character in the <pattern string>.
The use of an exclamation point (!) as the first character of a [charlist], is treated as a NOT indicator. The comparison results in a True when the character in the <literal string> is not one of the characters in the [charlist].  Any other use of the exclamation in the <pattern string> is treated as an exclamation point.
A range of characters can be specified in a [charlist] by using a hyphen (–) to separate the upper and lower bounds of the range. For example, [A-Z] results in a match if the corresponding character position in <literal string> contains any uppercase or lowercase letters in the range A–Z. Multiple ranges can be defined within one [charlist].
When a range of characters is specified, they must appear in ascending sort order. Thus, [A-Z] is a valid pattern, but [Z-A] is not.
To use a hyphen (–) in a [charlist] to be treated as a character for comparison, the hyphen must be the first character in the [charlist] or the last character.  At any other location within the [charlist] the hyphen identifies a range of characters delimited by the characters on either side of the hyphen.
The character sequence [] is considered a zero-length string ("").

 

Sample:

       The following segment of a script reads an adhoc file to determine if there is a charge date by determining if the part of the record matches the date pattern ##/##/##.

Read F

       REM Copy the charge date from the file.

Copy ChgDateFromFile File 78 8

       REM Check to see if there is a charge date for that record.

If ChgDateFromFile LIKE "##/##/##" GoTo Process

GoTo LoopThroughFile

 

:Process

       REM Copy the fields from the file into variables

See Also:

Complex If Comparisons