Author Topic: wrote this program...what can i do to make it better  (Read 4603 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
wrote this program...what can i do to make it better
« Reply #15 on: June 16, 2005, 02:02:04 PM »
**Real quick here**

There is T O N S more to recursion, but for now just focus on the basics. (I will say that you can --and will at sometime-- get into serious trouble for using recursion in your apps. Although its a very "efficient" way to accomplish a task on your part its not an "efficient" method for the computer. Recursion can, more often then not, become a HOG. It would be like driving a big ol cadalic; Its very nice and perdy, but its bad for gas millage.)

Okay, Thats enough about recursion. We learned something new and had fun playing arround with it, lets keep our attention on the task at hand. (Working on a better app.) And besides, we've actualy got a perdy cool procedure in the first one we created so we can use that one in your app if you like. But MP has a good point. And since we are just poking about trying to develop a neat lil app we should try to explore our options and see if we cant "beef up" a bit. So im gonna give you some homework now.

Look up "initget" in the help file and return to me the "bit codes". I also want you to explain to me what "initget" does.  

Now let's see if we cant get MP to share some more of his thoughts on the issue.

Sorry gotta run now. I'll be back in a bit.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
wrote this program...what can i do to make it better
« Reply #16 on: June 16, 2005, 02:10:12 PM »
Quote from: MP
Before this thread is finished make sure you mention initget too.

/suggestion

:)

You already did. :)

INITGET is a great function but with points it falls short.
Unless someone proves me wrong, you can still crash this code.
Code: [Select]
(defun c:test (/ pt)
  (initget 1)
  (setq pt (getpoint "\nPlease select a point: "))
  (princ)
)


by entering a number. If you enter a point like this 211,315
all is well and the initget will prevent you from just pressing ENTER.
But if you enter a single number 22 for example a point is returned that
is random, I think it is random.

Anyway it is fine for preventing the user from pressing enter only.
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.

dubb

  • Swamp Rat
  • Posts: 1105
wrote this program...what can i do to make it better
« Reply #17 on: June 16, 2005, 02:23:00 PM »
Quote from: Se7en

Look up "initget" in the help file and return to me the "bit codes". I also want you to explain to me what "initget" does.  .......................
....Sorry gotta run now. I'll be back in a bit.


thats great...ill do some research and do some coding with this new "initget" function...thanks.

i seem to like this "intget" function a lil more...brb...with some code..thanks cab!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
wrote this program...what can i do to make it better
« Reply #18 on: June 16, 2005, 04:21:57 PM »
OK, how about some overkill with the GETPOINT.
This will not return without a point whether picked or entered.
Entered points must be numbers separated with commas only, 2d or 3d OK.

Code: [Select]
;;;=======================[ getpoint_only.lsp ]=======================
;;; Author: Charles Alan Butler
;;; Version:  1.0 Jun. 16, 2005
;;; Purpose: Only get a point, do not return without one
;;; Sub_Routines: -None
;;; Arguments: -msg  string containing the prompt message
;;; Usage:  (getpoint_only msg)
;;; Returns: -the point picked
;;; Note: -User may enter a point at the command line 10,10 or 10,10,0
;;;====================================================================
(defun getpoint_only (msg / pt loop fuzz lastp)
  (setq loop  t
        fuzz  0.0001
        lastp (getvar "lastpoint")
  )
  (setq msg (strcat "\n" (cond (msg) ("Please select a point: "))))
  ;;  in case the user pressed escape last time here
  (if (< fuzz (distance '(1.9999 1.9999 0.0) (getvar "lastpoint")))
    (setvar "lastpoint" '(1.9999 1.9999 0.0))
    (setvar "lastpoint" '(1.8999 1.8999 0.0))
  )
  (while loop
    ;;  pt must meet the following requirements
    (if (and (setq pt (getpoint msg))    ; not nil
             (listp pt)                  ; must be a list
             ;;  do not allow bad numeric entry
             (< fuzz (distance pt (getvar "lastpoint")))
        )
      (setq loop nil) ; ok to exit, else
      (prompt "\nYou must select a point, please try again. ")
    )
  )
  (setvar "lastpoint" lastp)
  pt
)
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.