Progn

Discussion in 'AutoCAD' started by Adesu, May 31, 2004.

  1. Adesu

    Adesu Guest

    I am still learning about "progn",but rather difficult to understand it,can
    someone's inform to me,how to interpreting it with simple and clear,and give
    me sample,here original from autocad help.
    (if (= a b)
    (progn
    (princ "\nA = B ")
    (setq a (+ a 10)
    b (- b 10))
    ))
    Thanks a lot for kind
    Best regards
    Ade Suharna
     
    Adesu, May 31, 2004
    #1
  2. The progn function is used when more than one function is to be called when
    only 1 function is allowed.
    This is mainly used by the IF function to allow more than 1 expression to be
    evaluated.

    IF function in it's most basic form - only 1 expression evaluated when the
    IF function evaluates as true and 1 for false
    (if (= A B)
    (princ "\nA = B") ;1 line for if True
    (Princ "\nA /= B") ;1 line for if False
    )

    Complex Example -
    (if (= A B)
    (progn
    (princ "\nA = B") ;1st line for true expression
    (setq AB T) ;2nd line for true expression
    ..... ;more lines for true expression
    )
    (progn
    (princ "\nA /=B") ;1st line for false expression
    (setq AB nil) ;2nd line for false expression
    ..... ;more lines for true expression
    )
    )

    I lined your program up to better show the multiple expressions
    (if (= a b)
    (progn ;start of true expression
    (princ "\nA = B ") ;1st line for true expression
    (setq a (+ a 10) ;2nd line for true expression
    b (- b 10) ;continuation of 2nd line for true
    expression
    )
    ) ;end of true expression
    )

    Another approach could be -
    (if (= a b)
    (and
    (princ "\nA = B")
    (setq A (+ A 10)
    B (- B 10)
    )
    )
    )
     
    Alan Henderson @ A'cad Solutions, May 31, 2004
    #2
  3. Adesu

    Adesu Guest

    Hi Alan,thanks a lot for your suggest
     
    Adesu, Jun 3, 2004
    #3
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.
Similar Threads
There are no similar threads yet.
Loading...