Jump to content

end Lisp with if-function


Manuel_Kunde

Recommended Posts

Hi all, here is a snippet from a lisp.

At the end of diffrent commands, I want to ask the user if he want to do something more. How can I write in the if-function that if Request is "No", the Lisp is finished?

 

  (initget "Yes No")
    (setq request (getkword "Want to do something more? [Yes/No] ")
    )
  
    (if (wcmatch request "Yes")
      (alert "i will do some more commands..")
    )
  
      (if (wcmatch request "No")
      (alert "the lisp is finished")
    )

 

Link to comment
Share on other sites

I have added strcase, so you can also answer in lower case. If you don't do if for both cases, the program only terminates when "N" is present.

 

(initget (strcase "Y N"))
(setq request (getkword "Want to do something more? [Yes/No] "))
(if (wcmatch request "N")
 (vl-exit-with-error (alert "the lisp is finished"))
)
(alert "i will do some more commands..")

 

Edited by confutatis
  • Like 2
Link to comment
Share on other sites

Try this:

(initget "Yes No")
(while (= (getkword "\nInsert new command(s) [Yes/<No>]? ") "Yes")
 (initget "Yes No")
;;Your command(s) here
 (alert "Continue") ;;For test
)
(alert "Bye") ;;For test

 

Link to comment
Share on other sites

6 hours ago, BIGAL said:

nice acet function

 

Okay, that's simple and nice. What does the number 4 mean?

Is it possible to add a heading to the dialog box?

 

image.png.40570785247841cedeb13b9ae80484c9.png

Link to comment
Share on other sites

Add heading:

(setq yesno (acet-ui-message "Insert new command(s) [Yes/<No>]? " "MESSAGE" 4))

 

Last number 1:

Immagine0.png.8f4d3a0295e06676a2ecf7b08d7792f9.png

 

Last number 2:

Immagine1.png.694a9e4bb17d82871fe201cf8506e9ac.png

 

Last number 3:

Immagine2.png.00da3e44bf99faf222892f3f357003bb.png

 

Last number 4:

Immagine4.png.81a268dc7f1169d65e95ae2f9836af18.png

 

Last number 5:

Immagine5.png.6cfe3443e58e4bc0a6bd65295bfc2f63.png

 

Last number 6:

Immagine6.png.36ba826df7114514abed71e0efe9f96e.png

  • Like 1
Link to comment
Share on other sites

47 minutes ago, confutatis said:

Add heading:


(setq yesno (acet-ui-message "Insert new command(s) [Yes/<No>]? " "MESSAGE" 4))

 

 

I am excited, this is so amazing. Thank you for that.

Link to comment
Share on other sites

For someone else who wants to do the same:

 

Base types
0 = Acet:OK
1 = Acet:OKCANCEL
2 = Acet:ABORTRETRYIGNORE
3 = Acet:YESNOCANCEL
4 = Acet:YESNO
5 = Acet:RETRYCANCEL

Icons
16 = Acet:ICONSTOP
32 = Acet:ICONQUESTION
48 = Acet:ICONWARNING
64 = Acet:ICONINFORMATION

Default buttons
0 = Acet:DEFBUTTON1
256 = Acet:DEFBUTTON2
512 = Acet:DEFBUTTON3
768 = Acet:DEFBUTTON4

Return Values
Returns one of the following values: 

1 = Acet:IDOK
2 = Acet:IDCANCEL
3 = Acet:IDABORT
4 = Acet:IDRETRY
5 = Acet:IDIGNORE
6 = Acet:IDYES
7 = Acet:IDNO
8 = Acet:IDCLOSE
9 = Acet:IDHELP

  • Like 1
Link to comment
Share on other sites

Also another is DOS-LIB has lots of good functions.

 

My take on yes no look for multi radio buttons.lsp in Cadtutor Downloads.

 

image.png.ef259b3457d1acdcc2206fecfac42351.png

 

Edited by BIGAL
Link to comment
Share on other sites

On 9/3/2021 at 1:58 AM, BIGAL said:

Also another is DOS-LIB has lots of good functions.

 

My take on yes no look for multi radio buttons.lsp in Cadtutor Downloads.


Dos lib is not quite easy to install. The multi-radio-buttons lisp is very good, for multiple queries. But the acet-function is easier for yes / no dialog boxes. Thanks for the help with this post.

Link to comment
Share on other sites

A not really documented in Multi radio buttons is that the variable BUT holds the button number so a yes = 1 a No = 2. You don't have to use the string value.

(ah:butts but "h"  '("Yes or No" "Yes" "No"))

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...