<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Do nothing on Cancel (Dialog Box) in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9079990#M83161</link>
    <description>&lt;P&gt;Man, as usual - here comes dlanorh to the rescue. You are my autolisp hero. &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am in a middle of some work here but when I get a chance I will test this out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
    <pubDate>Thu, 10 Oct 2019 21:29:32 GMT</pubDate>
    <dc:creator>pmercader</dc:creator>
    <dc:date>2019-10-10T21:29:32Z</dc:date>
    <item>
      <title>Do nothing on Cancel (Dialog Box)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9079494#M83159</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have incorporated a dialog box on a lisp this community has helped me create, I added this dialog box on an insert lisp but I am having trouble with canceling out from the dialog box.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially when I click on cancel, what the lisp does is just carry on the previous action.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ie:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I click "ok", it inserts the block called for.&lt;/P&gt;&lt;P&gt;then if I call the lisp again and this time click "cancel" the lisp just inserts the previous block inserted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I thought to add an "(exit)" in the cancel action_tile like so&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(action_tile
    "cancel"
    "(done_dialog)
	 (setq result nil)
	&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt; (exit)&lt;/STRONG&gt;&lt;/FONT&gt;
	"
  &lt;/PRE&gt;&lt;P&gt;it does the job of not carrying out the previous action but I get this error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;; error: quit / exit abort&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can work with that but I dont want it to be an "error".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I fix this? Below is the DCL and the Lisp.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DCL :&lt;/P&gt;&lt;PRE&gt;inputbox : dialog
		{

	label = "Block Lookup Tool";
	width = 50;

	: text { key = "prompt"; }
	: edit_box { key = "ebox1"; allow_accept = true; }

	ok_cancel;
     		 
		}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LISP :&lt;/P&gt;&lt;PRE&gt;(defun inputbox (prompt title default)
  
  (setq dcl_id (load_dialog "inputbox.dcl"))
  (if (not (new_dialog "inputbox" dcl_id))
    (exit)
  )

  (set_tile "prompt" prompt)
  (set_tile "title" title)
  (set_tile "ebox1" default)
  (mode_tile "ebox1" 2)
  
  (action_tile
    "accept"
    "(setq inputvalue (get_tile \"ebox1\"))
     (done_dialog)
     (setq result T)"
  )
  (action_tile
    "cancel"
    "(done_dialog)
	 (setq result nil)
	 (exit)
	"
  

  )
  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
  
)
 
(princ)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 17:45:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9079494#M83159</guid>
      <dc:creator>pmercader</dc:creator>
      <dc:date>2019-10-10T17:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Do nothing on Cancel (Dialog Box)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9079839#M83160</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1797371"&gt;@pmercader&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have incorporated a dialog box on a lisp this community has helped me create, I added this dialog box on an insert lisp but I am having trouble with canceling out from the dialog box.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially when I click on cancel, what the lisp does is just carry on the previous action.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ie:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I click "ok", it inserts the block called for.&lt;/P&gt;&lt;P&gt;then if I call the lisp again and this time click "cancel" the lisp just inserts the previous block inserted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I thought to add an "(exit)" in the cancel action_tile like so&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(action_tile
    "cancel"
    "(done_dialog)
	 (setq result nil)
	&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt; (exit)&lt;/STRONG&gt;&lt;/FONT&gt;
	"
  &lt;/PRE&gt;&lt;P&gt;it does the job of not carrying out the previous action but I get this error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;; error: quit / exit abort&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can work with that but I dont want it to be an "error".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I fix this? Below is the DCL and the Lisp.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DCL :&lt;/P&gt;&lt;PRE&gt;inputbox : dialog
		{

	label = "Block Lookup Tool";
	width = 50;

	: text { key = "prompt"; }
	: edit_box { key = "ebox1"; allow_accept = true; }

	ok_cancel;
     		 
		}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LISP :&lt;/P&gt;&lt;PRE&gt;(defun inputbox (prompt title default)
  
  (setq dcl_id (load_dialog "inputbox.dcl"))
  (if (not (new_dialog "inputbox" dcl_id))
    (exit)
  )

  (set_tile "prompt" prompt)
  (set_tile "title" title)
  (set_tile "ebox1" default)
  (mode_tile "ebox1" 2)
  
  &lt;FONT color="#FF0000"&gt;(action_tile "accept" "(progn (setq inputvalue (get_tile \"ebox1\")) (done_dialog 1))")
  (action_tile "cancel" "(done_dialog 0)")&lt;/FONT&gt;  

  &lt;FONT color="#FF0000"&gt;(setq x_val (start_dialog))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;  (unload_dialog dcl_id)
 (if (= x_val 1) (setq result T) (setq result nil))&lt;/FONT&gt;
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Try this. If called like so (setq rtn (inputbox "prompt"&amp;nbsp; "title" "default")) the input box function will return T or nil which will be set in variable rtn (rtn = T or nil). You will need to make x_val a local variable.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 20:10:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9079839#M83160</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2019-10-10T20:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Do nothing on Cancel (Dialog Box)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9079990#M83161</link>
      <description>&lt;P&gt;Man, as usual - here comes dlanorh to the rescue. You are my autolisp hero. &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am in a middle of some work here but when I get a chance I will test this out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 21:29:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9079990#M83161</guid>
      <dc:creator>pmercader</dc:creator>
      <dc:date>2019-10-10T21:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Do nothing on Cancel (Dialog Box)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9080114#M83162</link>
      <description>Two items...&lt;BR /&gt;&lt;BR /&gt;When you make a call to done_dialog, nothing is evaluated afterwards.&lt;BR /&gt;I am (now) surprised that it does. However, follow this fundamental&lt;BR /&gt;principal when using done_dialog inside an action_tile. It makes&lt;BR /&gt;reading the program easier...&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;(action_tile "accept" "(GET_All_Dialog_Tile_States_Here)(done_dialog 1)")&lt;BR /&gt;(action_tile "cancel" "(done_dialog 0)")&lt;BR /&gt;;|&lt;BR /&gt;Let's take advantage of the optional return value of done_dialog to&lt;BR /&gt;determine weather to continue on with the program. The return value&lt;BR /&gt;is sent to start_dialog.&lt;BR /&gt;|;&lt;BR /&gt;(setq sd (start_dialog))&lt;BR /&gt;(if dcl_id (setq dcl_id (unload_dialog dcl_id)))&lt;BR /&gt;;|&lt;BR /&gt;Now that you have cleanly exited the user input section of your code,&lt;BR /&gt;determine the state of "sd" for the next section - "Execute" - of your code:&lt;BR /&gt;|;&lt;BR /&gt;(if (and sd (&amp;gt; sd 0))&lt;BR /&gt; (progn&lt;BR /&gt;  [in your case, command INSERT goes here]&lt;BR /&gt; );progn&lt;BR /&gt;);if&lt;BR /&gt;&lt;BR /&gt;???&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Oct 2019 22:39:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9080114#M83162</guid>
      <dc:creator>scot-65</dc:creator>
      <dc:date>2019-10-10T22:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Do nothing on Cancel (Dialog Box)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9080153#M83163</link>
      <description>&lt;P&gt;I tried doing dlanorh's advice but when clicking cancel it does go through with the insert. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; Maybe if i give more details you guys can help me better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a flow chart of what I want the lisp to do and attached is a zip file of the lisp and dcl file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies if have butchered the lisp, coding isnt really my field but I got it to do what i want except for the "click cancel" part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Lisp Flow Chart" style="width: 646px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/686563i0F8F542F48515183/image-size/large?v=v2&amp;amp;px=999" role="button" title="LISP_FLOWCHART.png" alt="Lisp Flow Chart" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Lisp Flow Chart&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 23:12:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9080153#M83163</guid>
      <dc:creator>pmercader</dc:creator>
      <dc:date>2019-10-10T23:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Do nothing on Cancel (Dialog Box)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9080348#M83164</link>
      <description>&lt;P&gt;The Ok and Cancel key can be checked need to look up my 2012 book, the Key of the&amp;nbsp; "Cancel" button is "cancel" so you can check the value of this key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Look into the dcl programming help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something like this&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;(action_tile "accept" "(done_dialog)")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;FONT&gt;(action_tile "cancel" &amp;nbsp;"(setq optout "Yes" ) &amp;nbsp; (done_dialog)")&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 03:30:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9080348#M83164</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2019-10-11T03:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Do nothing on Cancel (Dialog Box)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9080462#M83165</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically, we use modal dialog boxes (the only ones availble with DCL) to get user input(s).&lt;/P&gt;
&lt;P&gt;It is a good practice to separate concerns an the dialog box should interact with the calling function the same way as other input ( getXXX) function, i.e. just return a value (or a list or values) if the user clicked oK, or nil if the user cancelled.&lt;/P&gt;
&lt;P&gt;Handling the done_dialog value returned by start_dialog is a good way to get the "dialog result" which works whatever the dialog box.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a little example with an input box which can be called as a getXXX function:&lt;/P&gt;
&lt;PRE&gt;(if (setq val (inputbox "Hello" "Enter your first name:" ""))
  (alert (strcat "Hello " val "!"))
)&lt;/PRE&gt;
&lt;PRE&gt;(defun inputbox	(title msg val / temp file dcl_id result)

  ;; Create a temporary DCL file
  (setq	temp (vl-filename-mktemp "Tmp.dcl")
	file (open temp "w")
	ret  ""
  )

  ;; Write the file
  (write-line
      "InputBox:dialog{
          key = \"title\"; initial_focus = \"val\";
          spacer;
          :text{
              key = \"msg\";}
          spacer;
          :edit_box{
              key = \"val\"; edit_width = 36; allow_accept = true;}
          spacer;
          ok_cancel;}"
    file
  )
  (close file)

  ;; Open the dialog title
  (setq dcl_id (load_dialog temp))
  (if (not (new_dialog "InputBox" dcl_id))
    (exit)
  )
  (set_tile "title" title)
  (set_tile "msg" msg)
  (set_tile "val" val)
  (action_tile "val" "(setq val $value)")
  (action_tile "accept" "(done_dialog 1)")
  (action_tile "cancel" "(done_dialog 0)")
  (setq result (start_dialog))
  (unload_dialog dcl_id)

  ;; Delete the file
  (vl-file-delete temp)

  ;; Return the value if user clicked OK; else, nil
  (if (= 1 result)
    val
  )
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Oct 2019 06:03:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/do-nothing-on-cancel-dialog-box/m-p/9080462#M83165</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-10-11T06:03:58Z</dc:date>
    </item>
  </channel>
</rss>

