XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

string-equal


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

Syntax

(string-equal 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 -  T  if string1 equal to string2, NIL otherwise
Note: case is not significant with this function

Description

The 'string-equal' function takes two string arguments. It checks to see if the string arguments have the same values.  T  is returned if 'string1' is equal to 'string2', NIL is returned otherwise. This test is not case sensitive, the character '#\a' is considered to be the same as '#\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-equal "a" "b")            ; returns NIL
(string-equal "a" "a")            ; returns T
(string-equal "a" "A")            ; returns T
(string-equal "A" "a")            ; returns T
(string-equal "abc" "abc ")       ; returns NIL

(string-equal "J Smith" "K Smith" :start1 1 :start2 1)  ; strip off the first chars
                                                        ; returns T

(string-equal "abc" "123456789" :end2 3 :end1 3)        ; leave just the first 3 chars
                                                        ; returns NIL

Bug: The 'string-equal' function is listed in the original XLISP documentation as 'string-equalp'. In the XLISP interpreter a call to 'string-equalp' causes an error:

error: unbound function - STRING-EQUALP

The 'string-equal' function works exactly as the 'string-equalp' function described in the XLISP manual. This bug had obviously been corrected in the manual only but never in the interpreter. As the bug still exists with Nyquist 2.36 in July 2007 as well as all other XLISP 2.x implementations I know, I have changed both manuals to 'string-equal' even if I myself whould consider 'string-equalp' as the better name.

See the string-equal function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next