When I tried to compare a variable with a string, it gives me an error. I tried to compare it with (= ?a "s")
.
This is the full code example that produces the error:
(deffunction cierto (?a)
(if (= ?a "s")
then
(printout t TRUE crlf)
else
(printout t FALSE crlf)
)
)
The error:
Defining deffunction: cierto
[ARGACCES5] Function = expected argument #2 to be of type integer or float
ERROR:
(deffunction MAIN::cierto
(?a)
(if (= ?a "s")
FALSE
(deffunction cierto (?a)
(if (eq ?a "s")
then
(printout t TRUE crlf)
else
(printout t FALSE crlf)
)
)
(= ) is for comparing numbers (INTEGER or FLOAT) for equality.
(eq ) is for comparison of PRIMITIVE values and also comparison of types)
More information in the Basic Programming Guide (Section 12: Actions And Functions)
Alternative:
(deffunction cierto2 (?a)
(printout t (eq ?a "s") crlf)
)
You cold also use a SYMBOL s instead of a STRING "s".