check my syntax

Discussion in 'AutoCAD' started by mnash, Jun 4, 2004.

  1. mnash

    mnash Guest

    ( defun section ()
    (if
    ( cond
    (( = STK "L5x3x1/4" )( command "-insert" "L5x3x1_4" p1 "0.2" "0.2" "0" ))
    );cond
    );if
    (princ)
    );defun section


    I HAVE ALREADY DEFINED P1 AND STK IN A PREVIOUS STEP, any comments
     
    mnash, Jun 4, 2004
    #1
  2. mnash

    Murph Guest

    Why the "cond" statement? If you are only evalulating one item then just
    "if" works
    Unless you plan to add more conditons to check later.

    Murph
     
    Murph, Jun 4, 2004
    #2
  3. Global variables, <blech>.
    Non-descriptive function name.
    String comparison potential gotcha.
    Why the (if) ?
    I think I'd use a few more variables, to avoid mass (command) statements.

    (defun InsertSection (blkName insPt / insName sf ang)
    (setq blkName (strcase blkName))
    (cond
    ((= blkName "L5X3X1/4")
    (setq insName "L5x3x1_4" sf 0.2 ang 0.0))
    ;| next blkName condition here, similar to above |;
    ) ;_ closes cond
    (command "._-Insert" insName insPt sf sf ang)
    (princ))


    --
    R. Robert Bell


    ( defun section ()
    (if
    ( cond
    (( = STK "L5x3x1/4" )( command "-insert" "L5x3x1_4" p1 "0.2" "0.2" "0" ))
    );cond
    );if
    (princ)
    );defun section


    I HAVE ALREADY DEFINED P1 AND STK IN A PREVIOUS STEP, any comments
     
    R. Robert Bell, Jun 4, 2004
    #3
  4. mnash

    mnash Guest

    there are going to be hundreds of conditions in the future, I just to debug the first one
     
    mnash, Jun 4, 2004
    #4
  5. I'm aware of that. My sample code reflects that.

    --
    R. Robert Bell


    there are going to be hundreds of conditions in the future, I just to debug
    the first one
     
    R. Robert Bell, Jun 4, 2004
    #5
  6. mnash

    ECCAD Guest

    Robert,
    What happens if insName is nil ?

    (command "._-Insert" insName insPt sf sf ang)

    Bob
     
    ECCAD, Jun 5, 2004
    #6
  7. Since this is a subroutine, it is the programmer's responsibility to make
    sure the arguments passed to the subr are correct.

    --
    R. Robert Bell


    Robert,
    What happens if insName is nil ?

    (command "._-Insert" insName insPt sf sf ang)

    Bob
     
    R. Robert Bell, Jun 5, 2004
    #7
  8. However, you did spark a good point, my subr does not check for the
    existence of the block. (Hope they're located on the search path,
    BwaHaHa!!!)


    --
    R. Robert Bell


    Since this is a subroutine, it is the programmer's responsibility to make
    sure the arguments passed to the subr are correct.

    --
    R. Robert Bell


    Robert,
    What happens if insName is nil ?

    (command "._-Insert" insName insPt sf sf ang)

    Bob
     
    R. Robert Bell, Jun 5, 2004
    #8
Ask a Question

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.