GetKword default entering

Hi!

I want to set default "No" variable by entering enter. It works in AutoCAD LISP but bricscad lisp doesn't work.

when it questioning yes or no by pressing enter it will take default value is No, If I press y then go to program for Yes.

(setq ans1 (getkword "\nSecond view [Yes/No] <No>: "))

Thanks,

Avinash

Comments

  • Lee Mac has a good tutorial on default prompting with LISP.

    https://lee-mac.com/promptwithdefault.html

  • I can't comment on your specific situation, but bricsys acknowledged that initget/ getkword has some issues. Can you try a different setting for initget?

    I'd raise a support ticket. It's definitely something that needs fixing.

    Chris

  • Option 1

    (initget "Yes No")
    (setq ans (cond ((getkword "\nChoose [Yes/No] <No>: ")) ("No")))

    Option 2

    (initget "Yes No")
    (if (not (setq ans (getkword "\nChoose [Yes/No] <No>: "))) (setq ans "No") ans)

  • Thanks for your prompt reply

  • I don't use initget any more rather I have a make a dcl on the fly for this type of situation, it can be used in any code, has advantage can remember last choice, a couple of lines of code is all that is needed. Look in sample code at top a yes, no, example is there. Just save in a support path or put full path in the (Load statement as the code is demand loaded.

    Just a PS there is also a Acet yes no function.