Author Topic: One up and why! (MyLine)  (Read 12569 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10640
One up and why! (MyLine)
« on: August 22, 2006, 09:33:00 PM »
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: [Select]
(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)
       )
     )
  )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: One up and why! (MyLine)
« Reply #1 on: August 23, 2006, 12:45:10 AM »
This variant is easier... :-)
Code: [Select]
(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)

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: One up and why! (MyLine)
« Reply #2 on: August 23, 2006, 03:24:03 AM »
One up  (princ "\nYou have not entered a valid point; exiting now.")

Why .... changed spelling mistake

Code: [Select]
(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)
       )
     )
  )

Cool game Se7en. If this doesnt move to fast I might learn something about programming
« Last Edit: August 23, 2006, 03:25:09 AM by jonesy »
Thanks for explaining the word "many" to me, it means a lot.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: One up and why! (MyLine)
« Reply #3 on: August 23, 2006, 06:48:07 AM »
Go Jonesy! :)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: One up and why! (MyLine)
« Reply #4 on: August 23, 2006, 08:50:57 AM »
Code: [Select]
(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)

[*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
« Last Edit: August 23, 2006, 08:53:56 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: One up and why! (MyLine)
« Reply #5 on: August 23, 2006, 09:02:11 AM »
Code: [Select]
(DEFUN c: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
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;;
  (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)

One up and why
Added the C: to enable the user to type the command at the command line
Thanks for explaining the word "many" to me, it means a lot.

deegeecees

  • Guest
Re: One up and why! (MyLine)
« Reply #6 on: August 23, 2006, 10:10:42 AM »
Code: [Select]
(DEFUN c: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
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
  (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)

One up and why
Added recursive functionality (removed exiting quotes)

JVasco

  • Guest
Re: One up and why! (MyLine)
« Reply #7 on: August 23, 2006, 10:39:14 AM »
Code: [Select]
(DEFUN c: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
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
  (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)

One up and why
Added recursive functionality (removed exiting quotes)

I apologise, but I do not see the recursion.

lispman21

  • Guest
Re: One up and why! (MyLine)
« Reply #8 on: August 23, 2006, 10:49:35 AM »
The quotes that are highlighted are were removed.  This was the recursive functionality. (COMMAND "_.line" pt1 pt2 "")

lispman21

  • Guest
Re: One up and why! (MyLine)
« Reply #9 on: August 23, 2006, 11:15:40 AM »
One Up'ed and why

Made program more simplicit.  (did away with un-necessary progn's)


Code: [Select]
(DEFUN c:myline (/ cntr pt1 pt2)
(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: "
                    )
                  )
           )
    )
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
  )
  (IF pt2
    (COMMAND "_.line" pt1 pt2"")
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
  )
  (princ)
)

(princ)

deegeecees

  • Guest
Re: One up and why! (MyLine)
« Reply #10 on: August 23, 2006, 11:19:37 AM »
Quote
  ;;
  ;; 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
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)

A rev history would be nice. And what happened to my recursive functionality, or was that wrong?

uncoolperson

  • Guest
Re: One up and why! (MyLine)
« Reply #11 on: August 23, 2006, 11:21:55 AM »
Code: [Select]
;;
;; 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
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command

(DEFUN c:myline (/ cntr pt1 pt2)
  (SETQ cntr 1
pt1
(GETPOINT
  (STRCAT "\nEnter point number "
  (RTOS cntr 2 0)
  " please: "
  )
)
  )
  (while pt1
    (PROGN (SETQ cntr (1+ cntr))
  (SETQ pt2
 (GETPOINT
   pt1
   (STRCAT
     "\nEnter point number "
     (RTOS cntr 2 0)
     " please: "
   )
 )
  )
    )
    (IF pt2
      (progn (COMMAND "_.line" pt1 pt2 "") (setq pt1 pt2))
      (progn (PRINC
      "\nYou have not entered a valid point; exiting now."
    )
    (setq pt1 nil)

      )
    )
    (princ)
  )
)

(princ)

Hangman

  • Swamp Rat
  • Posts: 566
Re: One up and why! (MyLine)
« Reply #12 on: August 23, 2006, 11:28:23 AM »
Code: [Select]
  ;; Program 'MyLine'
  ;;
  ;; 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
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
  ;; 2006.08.23 Hangman ... replaced History & changed second point pick 'quit' to a repetitive second pick

(DEFUN c:myline (/ cntr pt1 pt2)
(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)
    )
  )
  (WHILE (= pt2 nil)
    (PROGN
      (PRINC
        "\nYou have not entered a valid point"
      )
      (SETQ pt2
        (GETPOINT
          pt1
          (STRCAT
            "\nEnter point number "
            (RTOS cntr 2 0)
            " please: "
          )
        )
      )
      (COMMAND "_.line" pt1 pt2)
    )
  )
  (princ)
)

(princ)

Reinserted the History and added a 'While' statement for repetitive point 2.
« Last Edit: August 23, 2006, 11:34:12 AM by Hangman »
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hangman

  • Swamp Rat
  • Posts: 566
Re: One up and why! (MyLine)
« Reply #13 on: August 23, 2006, 11:30:29 AM »
Doht !!!
Uncool posted before I could get my too cents in. 

Uncool !!!    :-D
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

deegeecees

  • Guest
Re: One up and why! (MyLine)
« Reply #14 on: August 23, 2006, 11:39:41 AM »
I had a feeling this would be a C.F. in that respect.

uncoolperson

  • Guest
Re: One up and why! (MyLine)
« Reply #15 on: August 23, 2006, 11:49:38 AM »
it gives the next poster the option of which way to continue the fun

anyone remember those choose your own adventure books?

LE

  • Guest
Re: One up and why! (MyLine)
« Reply #16 on: August 23, 2006, 11:51:04 AM »
Reply to the first post.

Code: [Select]
(defun MyLine  (/ cntr pt1 pt2)
  (setq cntr 1 ;; do not see the need of this variable
;; if it can be place as part of the
;; string prompt argument
;; of the GETPOINT function.
pt1
(getpoint
   (strcat
     "\nEnter point number "
     (rtos cntr 2 0) ;; wrong implementation/usage
      ;; if number is required here and it
      ;; is going to be an integer
      ;; then the ITOA function will be the best choice.
     " please: "
     )
   )
)
  (if pt1
    (progn
      (setq cntr (1+ cntr)) ;; again here if in advanced we know are
      ;; going to be two calls to
      ;; GETPOINT function - unnecessary
      (setq pt2 (getpoint pt1
  (strcat
    "\nEnter point number "
    (rtos cntr 2 0) ;; same as previous comment
    " please: "
    )
  )
    )
      )
    (progn
      (princ "\nYou have not entered a valid point; existing now.")
      (quit) ;; do not see very appropiate the use of QUIT
      )
    )
  (if pt2 ;; instead of using the QUIT function maybe will be better if
    ;; we use something like:
    ;; if (and pt1 p2) ...
    (command "_.line" pt1 pt2 "")
    (progn
      (princ "\nYou have not entered a valid point") ;; the message is not complete
      ;; it must mention that TWO points
      ;; are required.
      (quit) ;; better if we don't use it, and simple leave the above message
      ;; much cleaner with also including a (princ) at the end too.
      )
    )
  )

ronjonp

  • Needs a day job
  • Posts: 7529
Re: One up and why! (MyLine)
« Reply #17 on: August 23, 2006, 12:03:35 PM »
Here's my 2c.

Code: [Select]
;;
;; 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
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command
;; 2006.08.23 ronjonp ... removed extra setq, replaced "command" with entmake, made all functions lowercase (OCD)

(defun c:myline (/ cntr pt1 pt2)
  (setq cntr 1
pt1
(getpoint
   (strcat "\nEnter point number "
   (rtos cntr 2 0)
   " please: "
   )
)
  )
  (while pt1
    (progn (setq cntr (1+ cntr)
pt2
      (getpoint
pt1
(strcat
  "\nEnter point number "
  (rtos cntr 2 0)
  " please: "
)
      )
   )
    )
    (if pt2
      (progn (entmake
       (list
(cons 0 "LINE")
(cons 10 pt1)
(cons 11 pt2)
       )
     )
     (setq pt1 pt2)
      )
      (progn (princ
       "\nYou have not entered a valid point; exiting now."
     )
     (setq pt1 nil)
      )
    )
    (princ)
  )
)
(princ)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: One up and why! (MyLine)
« Reply #18 on: August 23, 2006, 12:11:29 PM »
Code: [Select]
;;
;; 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
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command
;; 2006.08.23 ronjonp ... removed extra setq, replaced "command" with entmake, made all functions lowercase (OCD)
;; 2006.08.23 T.Willey ... fixed the while statement (took out unnecessary stuff)

(defun c:myline (/ cntr pt1 pt2)
  (setq cntr 1
pt1
(getpoint
   (strcat "\nEnter point number "
   (rtos cntr 2 0)
   " please: "
   )
)
  )
  (while (setq cntr (1+ cntr)
pt2
      (getpoint
pt1
(strcat
  "\nEnter point number "
  (rtos cntr 2 0)
  " please: "
)
      )
   )
           (entmake
       (list
(cons 0 "LINE")
(cons 10 pt1)
(cons 11 pt2)
       )
     )
     (setq pt1 pt2)
    )
    (princ)
  )
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Hangman

  • Swamp Rat
  • Posts: 566
Re: One up and why! (MyLine)
« Reply #19 on: August 23, 2006, 01:21:37 PM »
Well, it's all nice & compact, but I prefer the option the (command .-line ... ) gives you and the personalization of the comments.
Although the way the code is manipulated in the last two posts are incredible.  I never new you could do stuff like that with some of those functions.  And thank you LE for putting in your comments of why you did what you did and how it's working.   Very Nice.  Keep going.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: One up and why! (MyLine)
« Reply #20 on: August 23, 2006, 03:01:07 PM »
Code: [Select]
;; 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
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command
;; 2006.08.23 ronjonp ... removed extra setq, replaced "command" with entmake, made all functions lowercase (OCD)
;; 2006.08.23 T.Willey ... fixed the while statement (took out unnecessary stuff)
;; 2006.08.23 MP ... renamed vars to be self describing, and/or fit my
;;                      sensibilities (I know, subjective),
;;                   reformatted to expose logic (subjective x 2),
;;                   changed rtos calls to itoa,
;;                   eliminated redundant prompt defs by employing a
;;                      template technique (pmt),
;;                   puckettized entmake code,
;;                   sorry I've got one shot at this and am tied up
;;                      for the balance of the day as I just resigned
;;                      my job of 11 years. As you can well imagine LOTS
;;                      of tidying up to do.

(defun c:MyLine ( / i pmt pt1 pt2 )

    (setq
        i     1
        pmt  '(strcat "\nEnter point number " (itoa i) ": ")
        pt1   (getpoint (eval pmt))
    )
   
    (while
   
        (setq
            i   (1+ i)
            pt2 (getpoint pt1 (eval pmt))
        )

        (entmake
            (append
               '((0 . "line"))
                (mapcar 'cons '(10 11) (list pt1 pt2))
            )   
        )
       
        (setq pt1 pt2)
       
    )
   
    (princ)
   
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7529
Re: One up and why! (MyLine)
« Reply #21 on: August 23, 2006, 03:10:47 PM »


Code: [Select]
;;
;; 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
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command
;; 2006.08.23 ronjonp ... removed extra setq, replaced "command" with entmake, made all functions lowercase (OCD) :)
;; 2006.08.23 T.Willey ... fixed the while statement (took out unnecessary stuff)
;; 2006.08.23 added (itoa cntr) per LE suggestion added echo last point to command line

(defun c:myline (/ cntr pt1 pt2)
  (setq cntr 1
pt1
(getpoint
   (strcat "\nEnter point number "
   (itoa cntr)
   " please: "
   )
)
  )
  (while (setq cntr (1+ cntr)
       pt2
    (getpoint
      pt1
      (strcat
"\n("
(rtos (car pt1))
","
(rtos (cadr pt1))
")<-last point - "
"Enter point number "
(itoa cntr)
": "
      )
    )
)
    (entmake
      (list
(cons 0 "LINE")
(cons 10 pt1)
(cons 11 pt2)
      )
    )
    (setq pt1 pt2)
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: One up and why! (MyLine)
« Reply #22 on: August 23, 2006, 03:11:32 PM »
Code: [Select]
;;
;; 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
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command
;; 2006.08.23 ronjonp ... removed extra setq, replaced "command" with entmake, made all functions lowercase (OCD)
;; 2006.08.23 T.Willey ... fixed the while statement (took out unnecessary stuff)
;; 2006.08.23 ElpanovEvgeniy ... add Undo, Close. Has deleted superfluous variables

(defun c:myline (/ lst)
  (setq
    lst (cons (getpoint (strcat "\nEnter point number 1 please: "))
     lst
)
  )
  (while
    (and
      lst
      (cond
((not (cdr lst))
(setq lst
(cons (getpoint (car lst)
(strcat "\nEnter point number 2 please: ")
     )
     lst
)
)
)
((not (cdddr lst))
(initget "Undo")
(setq
  lst (cons
(getpoint (cadr lst)
  (strcat "\nEnter point number "
  (itoa (1+ (/ (1- (length lst)) 2)))
  " please or [Undo] "
  )
)
lst
      )
)
)
((cdddr lst)
(initget "Close Undo")
(setq
  lst (cons
(getpoint (cadr lst)
  (strcat "\nEnter point number "
  (itoa (1+ (/ (1- (length lst)) 2)))
  " please or [Close/Undo] "
  )
)
lst
      )
)
)
(t nil)
      )
    )
     (cond
       ((= (car lst) "Undo")
(entdel (cadr lst))
(setq lst (cdddr lst))
       )
       ((= (car lst) "Close")
(entmakex
 (list
   (cons 0 "LINE")
   (cons 10 (caddr lst))
   (cons 11 (last lst))
 )
)
(setq lst nil)
       )
       ((cdddr lst)
(setq
 lst (cons
(entmakex
 (list
   (cons 0 "LINE")
   (cons 10 (car lst))
   (cons 11 (caddr lst))
 )
)
lst
     )
)
       )
       ((cdr lst)
(setq
 lst (cons
(entmakex
 (list
   (cons 0 "LINE")
   (cons 10 (car lst))
   (cons 11 (cadr lst))
 )
)
lst
     )
)
       )
     )
  )
  (princ)
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: One up and why! (MyLine)
« Reply #23 on: August 23, 2006, 03:15:03 PM »
;; 2006.08.23 MP ... renamed vars to be self describing, and/or fit my
;;                      sensibilities (I know, subjective),
;;                   reformatted to expose logic (subjective x 2),
;;                   changed rtos calls to itoa,
;;                   eliminated redundant prompt defs by employing a
;;                      template technique (pmt),
;;                   puckettized entmake code,
;;                   sorry I've got one shot at this and am tied up
;;                      for the balance of the day as I just resigned
;;                      my job of 11 years. As you can well imagine LOTS
;;                      of tidying up to do.

Hope for good reasons, and that you can enjoy your next endeavor.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: One up and why! (MyLine)
« Reply #24 on: August 23, 2006, 03:59:49 PM »
I am sure it must be for good, good luck Michael.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: One up and why! (MyLine)
« Reply #25 on: August 23, 2006, 04:37:13 PM »
Code: [Select]
;; 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
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command
;; 2006.08.23 ronjonp ... removed extra setq, replaced "command" with entmake, made all functions lowercase (OCD)
;; 2006.08.23 T.Willey ... fixed the while statement (took out unnecessary stuff)
;; 2006.08.23 MP ... renamed vars to be self describing, and/or fit my
;;                      sensibilities (I know, subjective),
;;                   reformatted to expose logic (subjective x 2),
;;                   changed rtos calls to itoa,
;;                   eliminated redundant prompt defs by employing a
;;                      template technique (pmt),
;;                   puckettized entmake code,
;;                   sorry I've got one shot at this and am tied up
;;                      for the balance of the day as I just resigned
;;                      my job of 11 years. As you can well imagine LOTS
;;                      of tidying up to do.
;; 2006.08.23 CAB ... revised mapcar & relocate setq i
(defun c:myline (/ i pmt pt1 pt2)

  (setq i   0
        pmt '(strcat "\nEnter point number " (itoa (setq i (1+ i))) ": ")
        pt1 (getpoint (eval pmt))
  )

  (while (setq pt2 (getpoint pt1 (eval pmt)))
    (entmake (mapcar 'cons '(0 10 11) (list "line" pt1 pt2)))
    (setq pt1 pt2)
  )

  (princ)

)
« Last Edit: August 23, 2006, 04:40:58 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: One up and why! (MyLine)
« Reply #26 on: August 23, 2006, 04:44:08 PM »
MP
With your talents & intellect your future will always be bright.
Try not to be stressed over it.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

deegeecees

  • Guest
Re: One up and why! (MyLine)
« Reply #27 on: August 23, 2006, 04:46:14 PM »
Should revise the file name to "My excruciating line" but thats just opinion and it would be alot to type.

 :-)

Ditto wut CAB sed.

uncoolperson

  • Guest
Re: One up and why! (MyLine)
« Reply #28 on: August 23, 2006, 05:22:04 PM »
..."My excruciating line"...

Code: [Select]
;; 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
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command
;; 2006.08.23 ronjonp ... removed extra setq, replaced "command" with entmake, made all functions lowercase (OCD)
;; 2006.08.23 T.Willey ... fixed the while statement (took out unnecessary stuff)
;; 2006.08.23 MP ... renamed vars to be self describing, and/or fit my
;;                      sensibilities (I know, subjective),
;;                   reformatted to expose logic (subjective x 2),
;;                   changed rtos calls to itoa,
;;                   eliminated redundant prompt defs by employing a
;;                      template technique (pmt),
;;                   puckettized entmake code,
;;                   sorry I've got one shot at this and am tied up
;;                      for the balance of the day as I just resigned
;;                      my job of 11 years. As you can well imagine LOTS
;;                      of tidying up to do.
;; 2006.08.23 CAB ... revised mapcar & relocate setq i
;; 2006.08.23 UnCoolPerson... moved line drawing to it's own defun (because we should be able to reuse it right?), edited c:mypoint create a list of pts to pass



(defun c:mypoint (/ pt1 pt2 pt1list pt2list)
  (setq i   0
pmt '(strcat "\nEnter point number " (itoa (setq i (1+ i))) ": ")
pt1 (getpoint (eval pmt))
  )

  (while (setq pt2 (getpoint pt1 (eval pmt)))
    (setq pt1list (append pt1list (list pt1)))
    (setq pt2list (append pt2list (list pt2)))

    (setq pt1 pt2)

  )
  (My_excruciating_lines pt1list pt2list)
(princ)
)

(defun My_excruciating_lines (pt1list pt2list / pt1 pt2)

  (mapcar '(lambda (pt1 pt2)
     (entmake
       (mapcar 'cons '(0 10 11) (list "line" pt1 pt2))
     )
   )
  pt1list
  pt2list
  )
)
« Last Edit: August 23, 2006, 05:24:12 PM by uncoolperson »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: One up and why! (MyLine)
« Reply #29 on: August 23, 2006, 05:33:33 PM »
Humm. No visual feed back, I don't care for that. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: One up and why! (MyLine)
« Reply #30 on: August 23, 2006, 05:52:40 PM »
One up and why!
Security measures initiated ... kwb 2006.08.23
Code: [Select]
((:protected . T) (:active-x . T) (:separate-namespace) (:load-file-list (:fas "KDUB_Routines")))—D
KDUB_ROUTINES
 FAS4-FILE ; Do not change it!
43829
1609 $ .....
0";
fixed_width = true;
}
}
}
}
ok_cancel;
}

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JohnK

  • Administrator
  • Seagull
  • Posts: 10640
Re: One up and why! (MyLine)
« Reply #31 on: August 23, 2006, 06:10:15 PM »
I see a few good points and see that some are following the rules but i want to say one thing:

This is a game, one of the reasons I choose lisp is becuase quite a few people know lisp--I was going to use C++ but--I figured more could participate. In this game you can only make ONE change at a time; if you see two spelling errors, you can only change one at a time.

You can convey your overall ideas and form a group, but if others dont agree with your ideas or just want to cause trouble, they...This is ment to be A LOT of fun.

I gave you three rules to follow...If we are following those rules and we go back thru the posts, what version of code are we on? I think we are back to Tracey's code.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

uncoolperson

  • Guest
Re: One up and why! (MyLine)
« Reply #32 on: August 23, 2006, 06:12:11 PM »
Security measures initiated ... kwb 2006.08.23

awesome... that's about it...

JohnK

  • Administrator
  • Seagull
  • Posts: 10640
Re: One up and why! (MyLine)
« Reply #33 on: August 23, 2006, 06:18:10 PM »
The quotes that are highlighted are were removed.  This was the recursive functionality. (COMMAND "_.line" pt1 pt2 "")

That's not recursion and I guess it could be called functional depending on your needs, but i dont know what ``recursive functionality'' is. Call it like it is: ``I left the line command open for continuation.'' or something like that.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10640
Re: One up and why! (MyLine)
« Reply #34 on: August 23, 2006, 06:21:50 PM »
ronjonp and LE, Dont reply to me personaly; thats not the point of the game. Try to sway the others to your way of thinking.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10640
Re: One up and why! (MyLine)
« Reply #35 on: August 23, 2006, 06:27:06 PM »
Guys, think a few poeple are on the right track. Tracey & Elpanov to name a quick few. I think Tracey cause she was the first one to make only ONE change, but sofar Elpanov, hasnt posted the Bold red letters signifying that he wants to make a submittal. I think because of the language barrier hes trying to convey his direction, has anyone payed attention? (I see a few points being discussed later in this thread, that he covered in his first point but i dont see anyone asking him.)

...I'm lost now that i read this thread.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

LE

  • Guest
Re: One up and why! (MyLine)
« Reply #36 on: August 23, 2006, 06:28:22 PM »
Sorry but I am not replying to you..... what I posted I did it here - unless there is another member using my initials....  :roll:  :-)

Also, let me know and I can remove my previous one and this one, I am in that mod today by the way....  :evil:

JohnK

  • Administrator
  • Seagull
  • Posts: 10640
Re: One up and why! (MyLine)
« Reply #37 on: August 23, 2006, 06:33:38 PM »
No, no LE, dont get me wrong, i was just using yours and ronjonp's posts to make a point. Thats it. Leave it man, otherwise things will get goofed up. I just wanted to say that when you make a point you want to try and convince the group that your ideas are the best. Thats all.

TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: One up and why! (MyLine)
« Reply #38 on: August 23, 2006, 07:19:05 PM »
"Rules ?? we don't want no stinking rules !"  :lol:


 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JohnK

  • Administrator
  • Seagull
  • Posts: 10640
Re: One up and why! (MyLine)
« Reply #39 on: August 24, 2006, 06:54:40 PM »
...Okay, i guess that game flopped.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Maverick®

  • Seagull
  • Posts: 14778
Re: One up and why! (MyLine)
« Reply #40 on: August 24, 2006, 07:07:08 PM »
I thought it looked like a fun game too.  I wonder if everyone had the box checked for notifying of post while typing?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: One up and why! (MyLine)
« Reply #41 on: August 24, 2006, 07:11:31 PM »
...Okay, i guess that game flopped.

That''ll learn ya for going all 'Monica' on us.

 :lmao:

<ps: I just been busy>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: One up and why! (MyLine)
« Reply #42 on: September 03, 2006, 04:40:22 AM »
Can we bring this game back. I was hoping to learn stuff from this game. It just went way too fast for a novice like me :-(
Thanks for explaining the word "many" to me, it means a lot.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: One up and why! (MyLine)
« Reply #43 on: September 03, 2006, 04:45:31 AM »
Can we bring this game back. I was hoping to learn stuff from this game. It just went way too fast for a novice like me :-(
Can, you have questions?
I am ready to help... :)

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: One up and why! (MyLine)
« Reply #44 on: September 03, 2006, 05:07:50 AM »
Thank you. I will have questions. I'll start trying to understand it tomorrow, and then post any questions I have.

Thanks for your offer
Tracey
Thanks for explaining the word "many" to me, it means a lot.