Code Red > AutoLISP (Vanilla / Visual)

One up and why! (MyLine)

(1/9) > >>

JohnK:
The rules of this game are very simple; ``one up'' the previous guy. You may only adjust one (1) thing about the previous persons program. For example, if you see a spelling error you may only change that in your next post. The second rule is that your ``one up'ed'' code MUST work. And the third and final rule is that you need to give a reason why your code is ``one up'ed'' from the previous. Beyond that, the sky's the limit. You may mutate the process and procedures to suit your needs. You may gang up in teams and try and get the program to mutate into something your team wants but the ``one up'', the ``working'' and the ``why'' rules must hold true. (If you are trying to mutate the procedure you either need to find a slick way of doing it, or make up a good enough reason not to cause a stink--No ``cause I wanted to'' allowed-.)

I will start off with a very simple program that has plenty potential to grow.

You may hold general discussions in this thread with your teammates if you feel like it--no private messages for recruiting you must hold all discussions here in the open.

Official ``one up'' code must be prefixed with the tags:
One up and Why:

...So without further adieu:

One up and Why:
Initial code.

--- Code: ---(defun MyLine ( / cntr pt1 pt2 )
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
   (setq cntr 1
         pt1
          (getpoint
            (strcat
               "\nEnter point number "
                 (rtos cntr 2 0)
                " please: "
                )
            )
          )
   (if pt1
      (progn
        (setq cntr (1+ cntr))
        (setq pt2 (getpoint pt1
                     (strcat
                        "\nEnter point number "
                         (rtos cntr 2 0)
                        " please: "
                       )
                     )
           )
        )
      (progn
        (princ "\nYou have not entered a valid point; existing now.")
        (quit)
        )
      )
   (if pt2
      (command "_.line" pt1 pt2 "")
      (progn
        (princ "\nYou have not entered a valid point")
        (quit)
       )
     )
  )

--- End code ---

ElpanovEvgeniy:
This variant is easier... :-)

--- Code: ---(defun MyLine (/ pt1 pt2)
  ;;
  ;; History:
  ;; 08.23.06 -- ElpanovEvgeniy
  ;;
  (cond
    ((not (setq pt1 (getpoint "\nEnter point number 1 please: "))
     )
     (princ "\nYou have not entered a valid point 1 ")
    )
    ((not (setq pt2 (getpoint pt1 "\nEnter point number 2 please: "))
     )
     (princ "\nYou have not entered a valid point 2 ")
    )
    (t
     (entmakex
       (list
'(0 . "LINE")
(cons 10 pt1)
(cons 11 pt2)
       )
     )
    )
  )
  (princ)
)
;test:
;(MyLine)
--- End code ---

jonesy:
One up  (princ "\nYou have not entered a valid point; exiting now.")

Why .... changed spelling mistake


--- Code: ---(defun MyLine ( / cntr pt1 pt2 )
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
   (setq cntr 1
         pt1
          (getpoint
            (strcat
               "\nEnter point number "
                 (rtos cntr 2 0)
                " please: "
                )
            )
          )
   (if pt1
      (progn
        (setq cntr (1+ cntr))
        (setq pt2 (getpoint pt1
                     (strcat
                        "\nEnter point number "
                         (rtos cntr 2 0)
                        " please: "
                       )
                     )
           )
        )
      (progn
        (princ "\nYou have not entered a valid point; exiting now.")
        (quit)
        )
      )
   (if pt2
      (command "_.line" pt1 pt2 "")
      (progn
        (princ "\nYou have not entered a valid point")
        (quit)
       )
     )
  )
--- End code ---

Cool game Se7en. If this doesnt move to fast I might learn something about programming

MickD:
Go Jonesy! :)

Kerry:

--- Code: ---(DEFUN myline (/ cntr pt1 pt2)
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
  ;;
  (SETQ cntr 1
        pt1
         (GETPOINT
           (STRCAT "\nEnter point number "
                   (RTOS cntr 2 0)
                   " please: "
           )
         )
  )
  (IF pt1
    (PROGN (SETQ cntr (1+ cntr))
           (SETQ pt2
                  (GETPOINT
                    pt1
                    (STRCAT
                      "\nEnter point number "
                      (RTOS cntr 2 0)
                      " please: "
                    )
                  )
           )
    )
    (PROGN
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
      (QUIT)
    )
  )
  (IF pt2
    (COMMAND "_.line" pt1 pt2 "")
    (PROGN
      (PRINC
        "\nYou have not entered a valid point"
      )
      (QUIT)
    )
  )
  (princ)
)

(princ)
--- End code ---

[*giggle*]

One up and Why:
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise

Navigation

[0] Message Index

[#] Next page

Go to full version