CAD Forums


Reply
Thread Tools Display Modes

Format for dtr

 
Adesu
Guest
Posts: n/a
 
      07-15-2004
Dear Lispers.
I want ask you alls,how the best place of "dtr",before defun (format 1) or
in defun (format 2),if it see in program procedure,thanks for your reply
Best regards
Ade Suharna

format 1

(defun dtr (a)
(* pi (/ a 180.0)))
(defun c:xx (/)
bla...bla...
)

format 2

(defun c:xx (/)
(defun dtr (a)
(* pi (/ a 180.0)))
bla...bla...
)


 
Reply With Quote
 
 
 
 
Paul Turvill
Guest
Posts: n/a
 
      07-15-2004
It's a matter of preference, I guess. Either will make the (dtr ...)
function available to other LISP routines, but format 2 will unnecessarily
redefine the function every time you run command XX. If you're a stickler
for "efficient" code, use format 1.
___

"Adesu" <(E-Mail Removed)> wrote in message
news:40f5db98_2@newsprd01...
> Dear Lispers.
> I want ask you alls,how the best place of "dtr",before defun (format 1) or
> in defun (format 2),if it see in program procedure,thanks for your reply



 
Reply With Quote
 
 
 
 
ECCAD
Guest
Posts: n/a
 
      07-15-2004
Ade,
My 2 cents:
I would say it depends. IF you are sending a program to someone (and it needs dtr..) then include it in the program. That way, you won't get beat-up for forgetting it..
IF you are doing a larger process, using many programs, then, include it in some loaded utility.

Bob
 
Reply With Quote
 
R. Robert Bell
Guest
Posts: n/a
 
      07-15-2004
One key point that both Paul and Bob missed was that your sample for format
2, as shown, will _definitely_ lead to bugs in the long run. Why? Because
you did not declare the subroutine's symbol as local.

So imagine this scenario for format 2, with two different .lsp files:

(defun C:XX (/ x)
(defun dtr (a)
(* pi (/ a 180.0)))
(setq x (dtr 30.0))
;| rest of code |;
)

(defun C:YY ()
(defun dtr (a)
(alert (strcat "My message is " a)))
(dtr "I'm going to cause a bug.")
;| rest of code |;
)

The code loaded last will win, breaking the _other_ program.

So, if you are going to embed subrs, either use names you know/guess will be
unique, or declare them as local symbols.

However, with (dtr), the subr will be used in many programs, so the best
approach is to have that subr in a separate .lsp file altogether, and
autoload the subr in the main functions. That way you need to maintain the
actual (dtr) code in one place only.

--
R. Robert Bell


"Adesu" <(E-Mail Removed)> wrote in message
news:40f5db98_2@newsprd01...
Dear Lispers.
I want ask you alls,how the best place of "dtr",before defun (format 1) or
in defun (format 2),if it see in program procedure,thanks for your reply
Best regards
Ade Suharna

format 1

(defun dtr (a)
(* pi (/ a 180.0)))
(defun c:xx (/)
bla...bla...
)

format 2

(defun c:xx (/)
(defun dtr (a)
(* pi (/ a 180.0)))
bla...bla...
)



 
Reply With Quote
 
ECCAD
Guest
Posts: n/a
 
      07-15-2004
<snip>IF you are doing a larger process, using many programs, then, include it in some loaded utility.<snip>
I don't think the intention was to 'redefine' the rtd function,
merely get it available.
Your sample is 're-writing' the function, and in doing so, yes, the 'last' loaded will survive..perhaps yielding unexpected results.

Bob
 
Reply With Quote
 
R. Robert Bell
Guest
Posts: n/a
 
      07-15-2004
X-zarchary! ;^)

--
R. Robert Bell


"ECCAD" <(E-Mail Removed)> wrote in message
news:13055928.1089907828472.JavaMail.jive@jiveforu m1...
<snip>IF you are doing a larger process, using many programs, then, include
it in some loaded utility.<snip>
I don't think the intention was to 'redefine' the rtd function,
merely get it available.
Your sample is 're-writing' the function, and in doing so, yes, the 'last'
loaded will survive..perhaps yielding unexpected results.

Bob


 
Reply With Quote
 
ECCAD
Guest
Posts: n/a
 
      07-15-2004
<Grin>
 
Reply With Quote
 
DEVItG
Guest
Posts: n/a
 
      07-19-2004
What do you mean????

a degree to radian defun???





"ECCAD" <(E-Mail Removed)> escribió en el mensaje
news:17618247.1089915124391.JavaMail.jive@jiveforu m2.autodesk.com...
> <Grin>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SLD format...??? ZR AutoCAD 3 04-21-2005 01:01 PM
Convert DWF to pdf or plt format Sam-Min AutoCAD Printing 3 07-21-2004 12:44 PM
convert from pro\E format in *.obj format jobbef Pro/Engineer & Creo Elements/Pro 0 02-09-2004 01:11 PM
Need help with format Aleksandar Mandic Pro/Engineer & Creo Elements/Pro 1 10-26-2003 10:39 PM
Autosketch 5.0 Not opening a .SKF file format, error "unexpected file format" domainadmin AutoSketch 1 08-15-2003 12:03 AM


All times are GMT. The time now is 05:51 PM.