If I have a string-typed slot, how can I distinguish between the string
"nil" and nil (null value) in a QueryResult? (Granted, using "nil" for a
string-typed slot value is perverse). Consider the interaction below.
Both "nil" and nil show up as "nil" using the getSymbol method.

Jess> (deftemplate foo (slot id (type INTEGER)) (slot bar (type
STRING)))
TRUE
Jess> (assert (foo (id 1) (bar "this is a normal string")))
FALSE
Jess> (assert (foo (id 2) (bar "the next row has bar = \"nil\"")))
<Fact-2278>
Jess> (assert (foo (id 3) (bar "nil")))
<Fact-2279>
Jess> (assert (foo (id 4) (bar "the next row has null bar")))
<Fact-2280>
Jess> (assert (foo (id 5)))
<Fact-2281>
Jess> (defquery list-foo (declare (variables)) (foo (id ?id) (bar
?bar)))
TRUE
Jess> (bind ?result (run-query* list-foo))
<Java-Object:jess.QueryResult>
Jess> (while (?result next) (printout t (?result getSymbol id) " "
(?result getSymbol bar) crlf))
1 this is a normal string
2 the next row has bar = "nil"
3 nil
4 the next row has null bar
5 nil

This is only an issue for string-typed slots. Numbers and booleans can't
have the string representation "nil" of course.

-------------------------------------------------------
Steve Solomon
USC Institute for Creative Technologies
[EMAIL PROTECTED]


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to