Reputation: 11367
I have an object with a multislot of INSTANCE. I have problems in getting instance's slot with one call. Example:
(defclass AUTOMA (is-a USER)
(slot uuid))
(defclass TUTOMA (is-a USER)
(multislot list
(type INSTANCE)))
(make-instance A1 of AUTOMA
(uuid a1))
(make-instance A2 of AUTOMA
(uuid a2))
(make-instance T1 of TUTOMA
(list [a1] [a2]))
I want to retrive the first object uuid of the multislot list.
1) Try with "first$":
CLIPS> (first$ (send [T1] get-list))
([a1])
CLIPS> (send (first$ (send [T1] get-list)) get-uuid)
[MSGFUN1] No applicable primary message-handlers found for get-uuid.
FALSE
2) Try with "implode$":
CLIPS> (implode$ (first$ (send [T1] get-list)))
"[a1]"
CLIPS> (send (implode$ (first$ (send [T1] get-list))) get-uuid)
[MSGFUN1] No applicable primary message-handlers found for get-uuid.
FALSE
It seems that both ([a1]) and "[a1]" are not good for the (send XXX get-uuid) command. Any suggestions, please?
Thank you Nic
Upvotes: 0
Views: 883
Reputation: 10757
First$ returns a multifield value and implode$ returns a string. You need to use an instance name. Use nth$ to retrieve a field from within a multifield. You also need to keep the case used for your instance names consistent:
CLIPS>
(defclass AUTOMA
(is-a USER)
(slot uuid))
CLIPS>
(defclass TUTOMA
(is-a USER)
(multislot list (type INSTANCE)))
CLIPS> (make-instance A1 of AUTOMA (uuid a1))
[A1]
CLIPS> (make-instance A2 of AUTOMA (uuid a2))
[A2]
CLIPS> (make-instance T1 of TUTOMA (list [A1] [A2]))
[T1]
CLIPS> (send (nth$ 1 (send [T1] get-list)) get-uuid)
a1
CLIPS>
Upvotes: 1