Lasso Soft Inc. > Home

[ string->compare ]

Method

[String->Compare] compares the first parameter to the base string and returns 0 if they are equal, 1 if the characters in the string are bitwise greater than the parameter, and -1 if the characters in the string are bitwise less than the parameter. Comparisons are made case insensitive by default. An optional -Case parameter compares the string taking case into account.

A second form of the method compares the parameter to a portion of a base string. The first parameter is the comparison string. The second parameter is an offset into the base string. And, the third parameter is the length of characters in the base string to be taken into account.

Additional optional fourth and fifth parameters specify an offset into the parameter string, and the length of characters in the parameter string to be taken into account, respectively. This allows a portion of the base string to be compared to a portion of the comparison string.

  • Syntax
'Base String'->compare('Param String')

'Base String'->compare('Param String', -case)

'Base String'->compare('Param String', 7, 6)

'Base String'->compare('Param String', 7, 6, 6, 6)
Examples
  • Beginner

To compare two strings:

Use the [String->Compare] method. The following examples compare the first parameter to the base string using the various forms.

Code

'Quick rhino'->compare('Quick shine')
'Quick rhino'->compare('ick', 3, 3)
'Quick rhino'->compare('icky', 3, 3, 1, 3)

Result

-1
0
0

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2014 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft