autoload
Why does not work the following autoload command?
on_doc_load.lsp: (autoload "filename" '("function"))
filename.lsp: (defun c:function (x / ) ... )
If I use functions without arguments it works fine.
Comments
-
Hmmm... I am not an expert but I don't think you can make commands that take arguements. There would be no mechanism to specify a value when running the command. My commands make use of the get* functions to interactively gather the information they require. I think you should have the same problem with commands taking arguments when you use (load "filename") also.
This is as I understand things Martin. If I am wrong perhaps someone will correct this.
Hope it helps.
0 -
No, the load command works: (load "filename"), with filename.lsp: (defun function (x / ) ... ). I start the function with: (function "arguments").
I am surprised at the different functionality.
0 -
Hi Martin. The difference is in your load example you are speaking of a function while with autoload you are dealing with commands. From you example when you are loading a file and calling a lisp function, even if you do it from the command line. The (function args) is a lisp expression that is being passed to the lisp interpreter.
The custom command ability provided by defining a function with the special "c:" prefix is a different thing. Here you have a lisp function named "c:function" that can be executed as a command "function" without the "(" and ")" and therefore not a lisp expression. You will notice you can still call the lisp function as defined (c:function) in a lisp expression but not (function).
In other words I can define a lisp function c:do_great_stuff and the Bricscad platform knows to add do_great_stuff to the list of commands available. When I enter do_great_stuff on the command line the program runs the c:do_great_stuff lisp function for me.
Hope that helps.
0 -
With other words:
(defun c:function...) creates a function, that can be started as a command outside of lisp. Arguments can not be committed.
(defun function... creates a function, that can be started only inside of lisp. Arguments can be committed.
Right?
0 -
Yes, but remember you can still call (c:function) in lisp if you wanted but you would have to include the c: prefix in that case.
0 -
Hello, Martin, Hello, Greg,
when using C: to define a command function, then it is not possible to provide arguments to the function ...
You can call (c:funx arg1 arg2) then, but then you can no longer run that command function as a command, by typing the name at command line.
As (defun c:funx ( arg1 arg2 / ...) ...) declares 2 arguments for function c:funx, you will get a runtime error when running FUNX as command.Another point : "function" is already a built-in Lisp function ... so you should not use this as a function name .-)
Did you try that autoload with Acad AutoLISP ? I just compared - Bricscad Lisp works mainly the same, regarding (autoload).
I tried in Acad :
(autoload "func.lsp" '("c:func"))=> (print func) - nil
=> (print c:func) - nil
=> (print c:c:func) - #<SUBR @06d1c85c C:C:FUNC> #<SUBR @06d1c85c C:C:FUNC>I guess this explains :-)
Many greetings, Torsten
0 -
Thanks for the confirming Torsten.
0