Author Topic: Help with DCL causing fatal error with function in action_tile  (Read 1601 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
Help with DCL causing fatal error with function in action_tile
« on: January 29, 2020, 02:47:50 PM »
I'm omitting code due to disclosure concerns I can pm or email the files to you if that helps.
I'm having trouble putting a function inside an action_tile. It will cause a fatal error. However if I place the function separately it seems to work well. I'm not sure what I'm doing wrong.

I get a fatal error using this method for the action_tile
Code: [Select]
(defun c:foo ( / dcl_id fn fname)
(vl-load-com)

;dcl file generator
(dcl_dialog)
(setq dcl_id (load_dialog fname))
     (if (not (new_dialog "temp" dcl_id))
(exit )
     );if
;
;
;
;
;
 
(action_tile "Accept "(setq d1 (nth (atoi(get_tile \"Rack Name\")) BlknLst))(setq d2(atoi(get_tile \"xoffset\")))(setq d3(atoi(get_tile \"yoffset\")))(xfunction d1 csvfile d2 d3)")
(start_dialog)
(unload_dialog dcl_id)
(vl-file-delete fname)
(princ)

);defun

This works for the action_tile however when I hit the escape button the function continues to execute
Code: [Select]
(defun c:foo ( / dcl_id fn fname)
(vl-load-com)

;dcl file generator
(dcl_dialog)
(setq dcl_id (load_dialog fname))
     (if (not (new_dialog "temp" dcl_id))
(exit )
     );if
;
;
;
;
;
 
(action_tile "Accept" "(setq d1 (nth (atoi(get_tile \"Rack Name\")) BlknLst))(setq d2(atoi(get_tile \"xoffset\")))(setq d3(atoi(get_tile \"yoffset\")))")
(xfunction d1 csvfile d2 d3)
(start_dialog)
(unload_dialog dcl_id)

(vl-file-delete fname)

(princ)

);defun

Rustabout

  • Newt
  • Posts: 135
Re: Help with DCL causing fatal error with function in action_tile
« Reply #1 on: January 29, 2020, 03:43:55 PM »
I'm sending a "general" response because I'm in a bit of a hurry. I had a similar problem but I might not have been getting a "fatal error". Just a heads up, you might only need to read the last sentence of this reply.

What I did to solve it: Instead of running a custom function from within the action_tile itself, I would 'setq' a flag that would later get passed to my routine, long after the dialog box did its thing and was unloaded. This advice more applies to the first bit of code you posted. We're limited to what can actually be placed in the action_tile expression but there are work-arounds, such as setting a flag of some sort (you might be doing this in your second snippet of code).

For the second bit of code you posted, I notice you aren't including "done_dialog" in your action_tile. And then you run your custom function before the dialog is unloaded. This will cause unpredictable results.

I would do something like this:

(action_tile "your_key" "(done_dialog) (setq myFlag \"some_value\")")

(start_dialog)

(unload_dialog "your_dialog_symbol")

(if (= myFlag "some_value")   *****or use 'cond'

    (xfunction........

As-is, you might get away with simply placing your 'xfunction' after unloading the dialog box.

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: Help with DCL causing fatal error with function in action_tile
« Reply #2 on: January 29, 2020, 04:03:45 PM »
I get a fatal error using this method for the action_tile
(action_tile "Accept "(progn (setq d1 ..... d2 d3))")

dubb

  • Swamp Rat
  • Posts: 1105
Re: Help with DCL causing fatal error with function in action_tile
« Reply #3 on: January 29, 2020, 05:31:53 PM »
Thanks Vovka, that explains alot to me. I got it work now.