Jump to content

Recommended Posts

Posted

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:

Posted

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)

Posted

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.

Posted
:P Too little too late it seems. Good description VVA
Posted

Nice once VVA, but, yes, I believe its just irresponsible function naming... :glare:

Posted
Nice once VVA, but, yes, I believe its just irresponsible function naming... :glare:

 

I wouldn't bet on it... I do this all the time. Useful for identification.

Posted
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

Posted
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...:P

Posted

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¢.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...