Hey there,
considering the fact that "init" is also a message handler, is there a way to pass arguments to it (using make-instance or initialize-instance ? .
I've got :
(defmessage-handlerMAIN::TESTCLASSinitafter(?printStatus)"May print sth at the time of creation of instance or re-initialazation"(if(eq ?printStatusyes)then(printoutt"Just created "(instance-name ?self))))
and then :
(make-instance of TESTCLASS (id 1)) : Message-handler 'init' after in class 'TESTCLASS' expected exactly 1 argument.
Obvious, right ?
So how do I pass the argument to it ?
I have come to know (through trial & error) that the following wont work :
The init message generated for make-instance and initialize-instance doesn't provide any mechanism for passing additional arguments. If you want to set up some debugging behavior for a class, I'd suggest using a shared slot instead of trying to pass additional parameters:
CLIPS(6.42/9/21)CLIPS>(defclassTESTCLASS(is-aUSER)(slotid)(slotprintStatus(storageshared)(defaultFALSE)))CLIPS>(defmessage-handlerTESTCLASSinitafter()(if?self:printStatusthen(printoutt"Just created "(instance-name?self)crlf)(bind?self:printStatusFALSE)))CLIPS>(make-instanceofTESTCLASS(id1))[gen1]CLIPS>(make-instanceofTESTCLASS(id2)(printStatusTRUE))Justcreated[gen2][gen2]CLIPS>(make-instanceofTESTCLASS(id3))[gen3]CLIPS>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey there,
considering the fact that "init" is also a message handler, is there a way to pass arguments to it (using make-instance or initialize-instance ? .
I've got :
and :
and then :
(make-instance of TESTCLASS (id 1)) : Message-handler 'init' after in class 'TESTCLASS' expected exactly 1 argument.
Obvious, right ?
So how do I pass the argument to it ?
I have come to know (through trial & error) that the following wont work :
I believe there is a way to use the message-handler thing like a c# constructor.
Thanks !!!
The init message generated for make-instance and initialize-instance doesn't provide any mechanism for passing additional arguments. If you want to set up some debugging behavior for a class, I'd suggest using a shared slot instead of trying to pass additional parameters:
Thanks there!!