goto function?

Discussion in 'AutoCAD' started by tader, Oct 25, 2004.

  1. tader

    tader Guest

    is there a way to jump to a certain line of the program if the "if" proves true? My "if" is if the user selects the same entity which shoudn't be done, ie.
    (if (equal ent1 ent2)
    (alert "You've picked the same line")
    How would i get that to allow the user to select again?

    TIA, Shawn
     
    tader, Oct 25, 2004
    #1
  2. tader

    Doug Broad Guest

    There is no goto in lisp.
    To loop and check conditions, use while
    or set up the problem recursively.
     
    Doug Broad, Oct 25, 2004
    #2
  3. tader

    Paul Turvill Guest

    (setq ent1 (car (entsel "\nSelect first line: ")))
    (while (equal (setq ent2 (car (entsel "\nSelect second line: "))) ent1)
    (alert "You've picked the same line!")
    );;while
    (do stuff with ent1 & ent2 here)
    ___

    true? My "if" is if the user selects the same entity which shoudn't be
    done, ie.
     
    Paul Turvill, Oct 26, 2004
    #3
  4. tader

    tader Guest

    Tanx Paul.
     
    tader, Oct 26, 2004
    #4
  5. tader

    tader Guest

    another quest. If the user selects the first line but then just hits enter w/out selecting another line, how would I get it to print "second line not selected "
    Something like this, but it doesn't work.

    (defun c:ce (/)
    (setq ent1 (car (entsel "\nSelect first line: ")))

    (while (equal (setq ent2 (car (entsel "\nSelect second line: "))) ent1)
    (alert "You've picked the same line!")
    (if
    (= ent2 nil
    (alert "You've selected nothing")))
    ) ;while

    (if (/= ent1 ent2)
    (print "Entities are different")
    (print "Entities are alike")
    )
    (princ)
    )
     
    tader, Oct 26, 2004
    #5
  6. tader

    Paul Turvill Guest

    (while (not (setq ent1 (car (entsel "\nSelect first line: ")))))
    (while
    (or
    (equal (setq ent2 (car (entsel "\nSelect second line: "))) ent1)
    (not ent2)
    );; or
    (alert
    (cond
    ((null ent2) "Nothing selected!")
    (T "You've picked the same line!")
    );;cond
    );;alert
    );;while
    (do stuff here)
    ___

    enter w/out selecting another line, how would I get it to print "second line
    not selected "
     
    Paul Turvill, Oct 26, 2004
    #6
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.