Reputation: 148
(bind ?existing_total_count (nth$ 2 (send ?INSTANCE ?get-INTS)))
(send (nth$ 2 (send ?INSTANCE put-INTS)) (+ ?total_count ?existing_total_count))
first line compiles fine, but second line throwing error Function send expected argument #2 to be of type symbol
I cant findout what the issue is. I am trying to update the second entry in slot INTS.
Upvotes: 0
Views: 52
Reputation: 10757
CLIPS>
(defclass A
(is-a USER)
(multislot INTS))
CLIPS> (make-instance [a] of A (INTS 1 2 3))
[a]
CLIPS> (send [a] print)
[a] of A
(INTS 1 2 3)
CLIPS> (bind ?INSTANCE [a])
[a]
CLIPS> (bind ?existing_total_count (nth$ 2 (send ?INSTANCE get-INTS)))
2
CLIPS> (bind ?total_count 3)
3
CLIPS> (slot-replace$ ?INSTANCE INTS 2 2 (+ ?total_count ?existing_total_count))
(1 5 3)
CLIPS> (send [a] print)
[a] of A
(INTS 1 5 3)
CLIPS> (bind ?total_count 5)
5
CLIPS> (send ?INSTANCE put-INTS (replace$ (send ?INSTANCE get-INTS) 2 2 (+ ?total_count ?existing_total_count)))
(1 7 3)
CLIPS> (send [a] print)
[a] of A
(INTS 1 7 3)
CLIPS>
Upvotes: 1