View Full Version : Loading Lisp routines from a reactor
2004-07-02, 01:52 PM
Does anyone have an example of loading a lisp routine using a reactor?
For some reason the (load "xxx") is causing an error within a routine I was working on.
2004-07-02, 03:57 PM
Not a solution, just an affirmation that I also get errors. I just added an automatic loading feature to a :vlr-unknownCommand reactor and get crashes when it tries to evaluate any C:-functions.
Example of error in backtrace: "ads_undef fails: <name num arc>: C:INSUL 2470 22"
Tried multiple loads and it stops at the first C: defun it encounters. If no C: defun exists it loads just fine.
2004-07-03, 02:31 PM
I don't think that loading lisp programs is inherently bad but
the lisp loaded must follow all the rules of reactor callbacks
if executed during the callback.(ie. no command functions...)
;;This works fine as long as "test.lsp" either doesn't execute
;;or executes under callback rules.
(setq cmdreact (vlr-command-reactor nil '((:vlr-commandended . testload))))
(defun testload (r cl)
(if (= "LINE" (CAR cl))
2004-07-03, 03:11 PM
I have had a breakthrough....
Let me explain.
Frequently I use a statements like this
(defun C:CHW () (load "CHW")(C:CHW))
in a file with many other statements like this to load lisp routines.
It was thinking...
Could the UnknownCommand reactor be used to load lisp routines?
It connot be done directly (because of the errors with loading routines from within a reactor) hence the post that started this thread.
I HAVE found a solution, that will allow me to "automatically" load and run lisp routines that have not been defined in a location (like the statement above) using the UnknownCommand reactor.
It is a hybrid application that uses a couple tricks.
First I used the vla-setVariable method to set the UserS5 system variable to the Unknown command string name inside the reactor.
I then created a VBA routine that monitors the system varaiable change events.
WHen the system variable is changed the vba event checks to see if it is the USERS5 system variable and if it is...
It uses the sendcommand method to load and run the lisp file.
I have added some checking mechanisms to make sure the filename is valid.
I would be glad to share this code if anyone is interested.
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.