OMEGA-ThundeR Posted May 23, 2017 Posted May 23, 2017 Hi, i'm trying to create a piece of code with a messagebox that ask a question (yes/no) which in turn should set an value that i can use in the 'main' command. (Defun FUNCTION (reply) (SETQ reply (ACET-UI-MESSAGE "Content of questionbox" "Title of questionbox" (+ Acet:YESNO Acet:ICONQuestion) ) ) ) As far as my 'function' knowledge goes this usually is defined within a command. i.e.: (Defun c:command () (defun FUNCTION ( / a) (do something) ) (FUNCTION (and do something with that function)) ) But i kind of want to use the function in multiple commands that work in a similar way, but don't want to add the lines of code to every command. So, how do i make the following work? (Defun FUNCTION (reply) (SETQ reply (ACET-UI-MESSAGE "Content of questionbox" "Title of questionbox" (+ Acet:YESNO Acet:ICONQuestion) ) ) ) (Defun c:CallFunction1 () FUNCTION ) (Defun c:CallFunction2 () FUNCTION ) (Defun c:CallFunction3 () FUNCTION ) Quote
Aftertouch Posted May 23, 2017 Posted May 23, 2017 (edited) Should look something like this. All three command's now open the dialog with the YES/NO question... So there is no variable for the three commands in this case. (defun FUNCTION ( / ) (setq reply (ACET-UI-MESSAGE "Choose dude " "Russells Dialog" (+ Acet:YESNO Acet:ICONQuestion))) ;; Yes = 6, No = 7 (if (= reply 6) (progn (ALERT "Yep") ) (progn (ALERT "Nope") ) ) ) (defun C:CallFunction1 ( / ) (FUNCTION) (princ) ) (defun C:CallFunction2 ( / ) (FUNCTION) (princ) ) (defun C:CallFunction3 ( / ) (FUNCTION) (princ) ) (princ) To do something different for each command, it could look like this: (defun TESTCOMMAND ( number / ) (setq reply (ACET-UI-MESSAGE "Choose dude " "Russells Dialog" (+ Acet:YESNO Acet:ICONQuestion))) ;; Yes = 6, No = 7 (if (= reply 6) (progn (cond ((= number 1) (princ "Voorwaarden voor CallFunction1") ) ((= number 2) (princ "Voorwaarden voor CallFunction2") ) ((= number 3) (princ "Voorwaarden voor CallFunction3") ) ) ) (progn (princ "NO, annuleren.") ) ) ) (defun C:CallFunction1 ( / ) (TESTCOMMAND 1) (princ) ) (defun C:CallFunction2 ( / ) (TESTCOMMAND 2) (princ) ) (defun C:CallFunction3 ( / ) (TESTCOMMAND 3) (princ) ) (princ) (TESTED AND WORKING) Edited May 23, 2017 by Aftertouch Quote
OMEGA-ThundeR Posted May 23, 2017 Author Posted May 23, 2017 Gives errors in both cases and i can't find a way to fix them . Seems to be going wrong in the command parts Quote
Aftertouch Posted May 23, 2017 Posted May 23, 2017 This is the code i tested and works perfect. (defun TESTCOMMAND ( number / ) (setq reply (ACET-UI-MESSAGE "Choose dude " "Russells Dialog" (+ Acet:YESNO Acet:ICONQuestion))) ;; Yes = 6, No = 7 (if (= reply 6) (progn (cond ((= number 1) (princ "Voorwaarden voor CallFunction1") ) ((= number 2) (princ "Voorwaarden voor CallFunction2") ) ((= number 3) (princ "Voorwaarden voor CallFunction3") ) ) ) (progn (princ "NO, annuleren.") ) ) ) (defun C:CallFunction1 ( / ) (TESTCOMMAND 1) (princ) ) (defun C:CallFunction2 ( / ) (TESTCOMMAND 2) (princ) ) (defun C:CallFunction3 ( / ) (TESTCOMMAND 3) (princ) ) (princ) Quote
Roy_043 Posted May 23, 2017 Posted May 23, 2017 IMO you should strive for a 'YesNo' function with this signature: (YesNoDialog "Title" "message") => T/nil (return value T or nil) Quote
OMEGA-ThundeR Posted May 23, 2017 Author Posted May 23, 2017 Seems to work fine now indeed... probably the word FUNCTION was the problem. Quote
Recommended Posts
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.