Author Topic: I'd like to change the default value of this lisp.  (Read 1768 times)

0 Members and 1 Guest are viewing this topic.

asami486

  • Guest
I'd like to change the default value of this lisp.
« on: January 21, 2017, 12:25:58 AM »
I'd like to change this lisp.
(Thank you VVA. eco 1.1)
Its default value is "No" (when I just push the SPACE KEY).
But I wanna change the value to "Yes"
(then it'll remove the objects except a boundary created by the lisp)

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: I'd like to change the default value of this lisp.
« Reply #1 on: January 21, 2017, 01:27:34 AM »

Try something like this :

Firstly, you need to understand that hitting ENTER or SPACEBAR on a getkword does not return any of the options
... it actually returns NIL

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (initget "Yes No")
  3. (setq result (getkword  "\nDelete objects? [Yes/No] <Yes> : ") )
  4.  
  5. SPACE or RETURN ==>nil
  6. y or Y          ==> "Yes"
  7. n or N          ==> "No"
  8. apples          ==> Invalid option keyword ... try again
  9.  

Then you need to write some code to catch the nil result, or a correct one

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (initget "Yes No")
  3.        (setq keyword (getkword "\nDelete objects? [Yes/No] <Yes> : "))
  4.        (if (or (not keyword) (= keyword "Yes"))
  5.          (alert "Proceed to delete")
  6.        )
  7.  


Once you are sure of your code replace the existing in the source :

Code - Auto/Visual Lisp: [Select]
  1.               (if pl
  2.                 (progn (initget "Yes No")
  3.                        (setq
  4.                          keyword (getkword "\nDelete objects? [Yes/No] <Yes> : ")
  5.                        )
  6.                        (if (or (not keyword) (= keyword "Yes"))
  7.                          (mapcar '(lambda (x)
  8.                                     (if (vlax-write-enabled-p x)
  9.                                       (vla-erase x)
  10.                                     )
  11.                                   )
  12.                                  obj
  13.                          )
  14.                        )
  15.                 )
  16.                 ;; else
  17.                 (princ "\nIt was not possible to construct a contour")
  18.               ) ;_ end of if
  19.  
  20.  
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: I'd like to change the default value of this lisp.
« Reply #2 on: January 21, 2017, 03:47:10 PM »
Check Lee Mac's tutorial about prompting with default option.
This is always a huge help when using getkword.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: I'd like to change the default value of this lisp.
« Reply #3 on: January 23, 2017, 09:03:02 AM »
Check out my version of the "RRB Default Method" (`my version' is just a very small improvement I did while standing on RRB's shoulders).

https://www.theswamp.org/index.php?topic=39042.msg442290#msg442290
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
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.