Jump to content

Can't close a DCL window


CyberAngel

Recommended Posts

This seems simple, but I can't make it work. The app opens a dialog so that the user can see the current parameters (e.g. current layer) and select a surface to use while drawing. The user presses a button labeled GO, which closes the dialog (with done_dialog) and returns to AutoLISP so the user can draw some swales from point to point. When the user presses enter at the start point prompt, the drafting loop closes and the dialog opens again (with start_dialog). All of that works properly.

 

There's another button named QUIT. When the user presses it, the app should close the dialog box, exit the AutoLISP function, and return to the command prompt. I have an action tile function that calls done_dialog and exit. When I press QUIT, though, I wind up back in the drafting loop, with a prompt for the start point of the swale.

 

The dcl_mode flag was supposed to end the outer loop when the QUIT happened, but I'm not sure where the DCL ends and the AutoLISP begins, and I don't think the flag is getting read at all. The QUIT action is supposed to end the function, but I think it disappears once the dialog closes; I removed the done_dialog call so it would go straight to exit, but that doesn't work either.

 

Here's the relevant code:

 

(defun surf_load ()
  ; ... load data ...
  (action_tile "GO" "(done_dialog 2)" )
  (action_tile "QUIT" "progn (
    (setq dcl_mode nil)
    (done_dialog 0)
    (exit) )"
  )
  (start_dialog)
) ; end surf_load

(defun c:swale_label ()
  ; initialize our function (first cycle only)
  (vl-load-com)
  (load_dialog "swale_label.dcl")
  (surf_load)
  (setq dcl_mode T) ; so dialog loop will start
; main processing loop
  ; dialog was open, GO pressed, now we're at prompt
  (while dcl_mode
    (while (setq pt_start (getpoint "\nStart point: "))
;  ... draw swale ...
    ) ; end draw mode while
    (surf_load) ; user finished, re-open dialog
  ) ; end main while
  (unload_dialog swale_label)
) ; end function

 

Update: I changed the entire action tile expression for quit to "(exit)," which gives me the proper behavior (the app stops) but displays the very redundant message "error: quit / exit abort". Guess I'll just turn off the echo so as not to worry the user.

 

Scratching My D Head: DCL seems so simple, I model my code on examples I find online, yet it never does what I expect it to do.

Edited by CyberAngel
added update
Link to comment
Share on other sites

To get rid of that anoying message : "error: quit / exit abort" you colud build error handler, but to me I never excluded it - always used (if msg (prompt msg)) in handler... Take a look at Lee's error handlers - he escaped that message almost always...

  • Thanks 1
Link to comment
Share on other sites

The action_tile for "quit" is incorrect, should be something like this:

  (action_tile "QUIT" "(setq dcl_mode nil) (done_dialog 0)")

Because the ( comes before progn instead of after.

And because you cannot do multiline strings in lisp. If you want an enter inside a string, use \n and if you want the code to be on multiple lines, use strcat.

 

To get rid of the quit/exit message, you can just not use (exit) there and the function should finish normally.

Edited by dexus
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...