Why repeat jumping

Discussion in 'AutoCAD' started by Adesu, Mar 3, 2005.

  1. Adesu

    Adesu Guest

    _$ (setq cnt 0)
    (setq rad 0)
    (setq n 200)
    (repeat n
    (cond ((and (>= cnt rad)(< n rad))))
    (setq rad (+ cnt rad))
    (princ "\n")(princ "(setq rad")(princ " ")
    (princ rad)(princ ")")
    (setq cnt (1+ cnt))
    )
    0
    0
    200

    (setq rad 0)
    (setq rad 1)
    (setq rad 3)
    (setq rad 6)
    (setq rad 10)
    (setq rad 15)
    (setq rad 21)
    (setq rad 28)
    ---------------------------etc.....

    Why my repeat program jumping,I would plan like this

    (setq rad 0)
    (setq rad 1)
    (setq rad 2)
    (setq rad 3)
    (setq rad 4)
    (setq rad 5)
    (setq rad 6)
    (setq rad 7)
    ---------------------------etc.....
     
    Adesu, Mar 3, 2005
    #1
  2. Adesu

    Jürg Menzi Guest

    Adesu

    Reread your code and you will find out why...

    Cheers
     
    Jürg Menzi, Mar 3, 2005
    #2
  3. Adesu

    Jeff Mishler Guest

    Look closely, Ade. It is doing exactly what you have told it to do ;-)

    first run:
    rad = 0
    cnt=0
    rad=0+0

    second run
    rad=0
    cnt=1
    rad=1+0

    third run
    rad=1
    cnt=2
    rad=1+2

    fourth run
    rad=3
    cnt=3
    rad=3+3

    fifth run
    rad=6
    cnt=4
    rad=6+4

    etc.
     
    Jeff Mishler, Mar 3, 2005
    #3
  4. or beautify
     
    Cut-Throat Jake, Mar 3, 2005
    #4
  5. Adesu

    Adesu Guest

    It's perfect,I 've got it
    _$ (setq cnt 1)
    (setq rad 0)
    (setq n 200)
    (repeat n
    (cond ((and (>= cnt rad)(< cnt rad))))
    (setq rad (+ 1 rad)) ; this problem
    here
    (princ "\n")(princ "(setq rad")(princ " ")
    (princ rad)(princ ")")
    (setq cnt (1+ cnt))
    )
    1
    0
    200

    (setq rad 1)
    (setq rad 2)
    (setq rad 3)
    (setq rad 4)
    (setq rad 5)
    (setq rad 6)
    (setq rad 7)
    ;----------------------(snip)
     
    Adesu, Mar 14, 2005
    #5
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.