bartdewilde Posted June 16, 2009 Posted June 16, 2009 hello i'm starting with autocad lisp i've learnd that you start a routine with (defun c:name ....) but now i've found a program that start with (defun cb:hdis (/ld) this comes back with the variables if (= (type cb:ld) 'str i understand the meanig of this code exept what te cb: means can someone tell me what's the difference between defun c: and defun cb: Quote
VVA Posted June 16, 2009 Posted June 16, 2009 By analogy to this article, I have written article on use of a code from a forum in Russian, where has a little expanded the description. As I not so well know English, therefore I will take advantage of machine translation. I hope, it will be clear, and if is not present, me will correct. Command or function? To begin with it is necessary to be defined, that at us: a command or function? It is a little theory. In the description practically any code there is such line, as (defun … And then after her something there it is written. And so that there is written and is a function name. If the first symbols are C:, function is ready to a call from a command line. If such is not present to cause function it is necessary, concluding her name in parentheses. For example, there is a function (defun c:test () ) It to cause since a command line it is possible directly: Command: test Also actions And here the such: (defun test () ) It will be possible to cause only so: Command: (test) Also actions . From the point of view of AutoCAD'a it is 2 different modules In your case it is function and it needs to be caused so: (cb:hdis) Quote
Commandobill Posted June 16, 2009 Posted June 16, 2009 I believe I've seen that lisp before. "cb:" doesnt actually do anything. That code is just a function. if you were to type in "hdis" as a command it wouldnt do anything. but if you were to use it like this (cb:hdis) it would run. Why they named it that way is unknown to me but im sure they had their reasons. Quote
Commandobill Posted June 16, 2009 Posted June 16, 2009 Too little too late it seems. Good description VVA Quote
Lee Mac Posted June 16, 2009 Posted June 16, 2009 Nice once VVA, but, yes, I believe its just irresponsible function naming... Quote
rkmcswain Posted June 16, 2009 Posted June 16, 2009 Nice once VVA, but, yes, I believe its just irresponsible function naming... I wouldn't bet on it... I do this all the time. Useful for identification. Quote
David Bethel Posted June 16, 2009 Posted June 16, 2009 I wouldn't bet on it... I do this all the time. Useful for identification. I agree. I use function name prefixes all of the time. My preference is to use an underscore delimiter , but a colon is just as valid. My $0.02 -David Quote
Lee Mac Posted June 16, 2009 Posted June 16, 2009 I wouldn't bet on it... I do this all the time. Useful for identification. You mean using the function syntax as a prefix for sub_routines - I suppose its good for reference, but the function begins with a c..: I suppose it could confuse the LISP novice... Quote
rkmcswain Posted June 16, 2009 Posted June 16, 2009 Possibly, but still nothing wrong with it. I do this sometimes within the same file. Say my file (and main function is named) CHTXT - i might name my internal functions things like: (defun chtxt:myfunc () (blah_blah) ) Of course, like David says, just my 2¢. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.