XLISP string/=

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# string/=

Type: | - | function (subr)
Source: | - | xlstr.c

## Syntax

(string/= string1 string2 [key offset] ... )
  stringN - a string expression
  key - a keyword [one of :start1 :start2 :end1 :end2]
  offset - an optional integer expression for a keyword
  returns - a non-NIL value if string1 is not equal to string2, NIL otherwise
  Note: case is significant with this function

## Description

The 'string/=' [string-not-equal] function takes two string arguments. A non-NIL value is returned if 'string1' is not equal to 'string2', otherwise NIL is returned. The non-NIL value returned is the integer index of the first character of 'string1' which is char/= [char-not-equal] to the corresponding character of 'string2'. This test is case sensitive, the character '#\a' is different and of greater ASCII value than '#\A'.

The keyword arguments allow for accessing substrings within 'string1' and 'string2'. The keyword arguments each require a keyword ':start1', ':end1', ':start2' or ':end2' and a single integer expression as a pair with the keyword first and the integer second. The pairs may be in any order. The ':startN' keywords specify the starting offset of the substring. A value of 0 starts the string at the beginning [no offset]. The ':endN' keywords specify the ending offset of the substring. A value of 3 ends the string after the 3rd character [an offset of 3 characters].

## Examples

    (string/= "a" "b")           ; returns 0
    (string/= "a" "a")           ; returns NIL
    (string/= "a" "A")           ; returns 0
    (string/= "A" "a")           ; returns 0
    (string/= "abc" "abc ")      ; returns 3

    (string/= "J Smith" "K Smith" :start1 1 :start2 1)  ; returns NIL
    (string/= "abc" "123456789" :end2 3 :end1 3)        ; returns 0

Note: Be sure that the 'string/=' function is properly typed in. The '/' is a forward slash. It is possible to mistakenly type a '\' backslash. This is especially easy because the character mechanism is '#\a'. If you do use the backslash, no error will be reported because backslash is the single escape character and the XLISP reader will evaluate 'string\=' as 'string='. No error will be reported, but the sense of the test is reversed.

See the string/= function in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference