Format for dtr

Discussion in 'AutoCAD' started by Adesu, Jul 15, 2004.

  1. Adesu

    Adesu Guest

    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...
    )
     
    Adesu, Jul 15, 2004
    #1
    1. Advertisements

  2. Adesu

    Paul Turvill Guest

    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" <> 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
     
    Paul Turvill, Jul 15, 2004
    #2
    1. Advertisements

  3. Adesu

    ECCAD Guest

    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
     
    ECCAD, Jul 15, 2004
    #3
  4. 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" <> 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...
    )
     
    R. Robert Bell, Jul 15, 2004
    #4
  5. Adesu

    ECCAD Guest

    <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
     
    ECCAD, Jul 15, 2004
    #5
  6. X-zarchary! ;^)

    --
    R. Robert Bell


    "ECCAD" <> wrote in message
    news:13055928.1089907828472.JavaMail.jive@jiveforum1...
    <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
     
    R. Robert Bell, Jul 15, 2004
    #6
  7. Adesu

    ECCAD Guest

    <Grin>
     
    ECCAD, Jul 15, 2004
    #7
  8. Adesu

    DEVItG Guest

    What do you mean????

    a degree to radian defun???





    "ECCAD" <> escribió en el mensaje
    news:...
    > <Grin>
     
    DEVItG, Jul 19, 2004
    #8
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Steffen Haugk

    get R2004 to save in R2000 format - repeat

    Steffen Haugk, Jul 22, 2003, in forum: AutoCAD
    Replies:
    0
    Views:
    326
    Steffen Haugk
    Jul 22, 2003
  2. Jan-Mikael Kristiansson

    database text format

    Jan-Mikael Kristiansson, Aug 6, 2003, in forum: AutoCAD
    Replies:
    4
    Views:
    244
    Ed Jobe
    Aug 7, 2003
  3. mclosson

    Save wblock in 2000 format

    mclosson, Feb 25, 2004, in forum: AutoCAD
    Replies:
    8
    Views:
    424
    dblaha
    May 11, 2004
  4. ghiggins457

    error: no function definition: DTR

    ghiggins457, Mar 2, 2004, in forum: AutoCAD
    Replies:
    2
    Views:
    941
    Allen Johnson
    Mar 2, 2004
  5. Adesu

    Dtr and Rtd

    Adesu, Jun 14, 2004, in forum: AutoCAD
    Replies:
    3
    Views:
    719
    Adesu
    Jun 14, 2004
  6. jobbef

    convert from pro\E format in *.obj format

    jobbef, Feb 9, 2004, in forum: Pro/Engineer & Creo Elements/Pro
    Replies:
    0
    Views:
    622
    jobbef
    Feb 9, 2004
  7. Greg McLandsborough

    polar, dtr, rtd

    Greg McLandsborough, Jun 4, 2004, in forum: AutoCAD
    Replies:
    1
    Views:
    327
  8. domainadmin
    Replies:
    1
    Views:
    591
    Paul Jackson
    Aug 15, 2003
Loading...