I want to constrain my allowed integers in a slot with a multifieldvariable.
So instead of:
CLIPS> (deftemplate foo (slot constr-integers (allowed-integers 1 3 4 7)))
I wanted do do something like this:
CLIPS> (bind ?multifieldvariable (create$ 1 3 4 7))
(1 3 4 7)
CLIPS> (deftemplate bar (slot constr-integers (allowed-integers ?multifieldvariable)))
[PRNTUTIL2] Syntax Error: Check appropriate syntax for allowed-integers attribute.
ERROR:
(deftemplate MAIN::bar
(slot constr-integers (allowed-integers ?multifieldvariable
I know how to work around this issue, but maybe there is a way to do it in a more elegant way.
Best regards, Sebastian
You can only do it by dynamically creating the deftemplate with a build function call:
CLIPS> (bind ?multifieldvariable (create$ 1 3 4 7))
(1 3 4 7)
CLIPS>
(build (str-cat "(deftemplate bar (slot constr-integers (allowed-integers "
(implode$ ?multifieldvariable)
")))"))
TRUE
CLIPS> (ppdeftemplate bar)
(deftemplate MAIN::bar
(slot constr-integers (allowed-integers 1 3 4 7)))
CLIPS>