TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Visual DCL Programming => Topic started by: XXL66 on December 05, 2015, 03:20:47 AM

Title: write DCL title at runtime
Post by: XXL66 on December 05, 2015, 03:20:47 AM
Is it possible ?

At an adesk forum someone wrote (set_tile "title" "This is the dialog title")
would do the trick but it doesn't seem to work (at least not in bcad).

I do not want to write the dialog on the fly.

ty !
Title: Re: write DCL title at runtime
Post by: Kerry on December 05, 2015, 03:24:44 AM
Please show us a sample DCL and a sample lisp.


added:
or have a look here:
http://web2.iadfw.net/terrycad/Tutorials/MyDialogs.htm#MyAlert1

Title: Re: write DCL title at runtime
Post by: ur_naz on December 05, 2015, 07:24:39 AM
In short use 'key'  attribute to change the dialog title
Code: [Select]
main : dialog {
  key = "title";
  // ...
}

Code - Auto/Visual Lisp: [Select]
  1. (set_tile "title" "This is the dialog title")
Title: Re: write DCL title at runtime
Post by: ymg on December 05, 2015, 12:14:01 PM
Not sure what the OP has in mind, but if he wants to change the Label that is the title
of a dialog box, he must generate the dcl on the fly.

The method proposed by ur-naz changes the key value of  tile named "Title",
the label that appears at top of dcl will not be changed.

ymg
Title: Re: write DCL title at runtime
Post by: Lee Mac on December 05, 2015, 12:26:47 PM
Not sure what the OP has in mind, but if he wants to change the Label that is the title
of a dialog box, he must generate the dcl on the fly.

The method proposed by ur-naz changes the key value of  tile named "Title",
the label that appears at top of dcl will not be changed.

I disagree - the method proposed by ur_naz is correct & effective (in AutoCAD at least), I use this method frequently.
Title: Re: write DCL title at runtime
Post by: Lee Mac on December 05, 2015, 12:37:04 PM
Here is an example to demonstrate this method:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / *error* dch dcl des )
  2.  
  3.     (defun *error* ( msg )
  4.         (if (< 0 dch) (unload_dialog dch))
  5.         (if (= 'file (type des)) (close des))
  6.         (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl))
  7.         (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
  8.             (princ (strcat "\nError: " msg))
  9.         )
  10.         (princ)
  11.     )
  12.  
  13.     (if
  14.         (and
  15.             (setq dcl (vl-filename-mktemp "tmp.dcl"))
  16.             (setq des (open dcl "w"))
  17.             (write-line
  18.                 (strcat
  19.                     "tmp : dialog { key = \"dcl\"; spacer_1;"
  20.                     ": text       { label = \"New dialog title:\"; } : row {"
  21.                     ": edit_box   { key = \"edt\"; width = 30; fixed_width = true; }"
  22.                     ": button     { key = \"chg\"; fixed_width = true; label = \"Change\"; }"
  23.                     "} spacer_1; ok_only; }"
  24.                 )
  25.                 des
  26.             )
  27.             (not (setq des (close des)))
  28.             (< 0 (setq dch (load_dialog dcl)))
  29.             (new_dialog "tmp" dch)
  30.         )
  31.         (progn
  32.             (set_tile "edt" (set_tile "dcl" "Default Dialog Title"))
  33.             (action_tile "chg" "(set_tile \"dcl\" (get_tile \"edt\"))")
  34.             (start_dialog)
  35.         )
  36.     )
  37.     (*error* nil)
  38.     (princ)
  39. )

Note that the above generates the DCL file at run-time for convenience, but this is not absolutely necessary.

Title: Re: write DCL title at runtime
Post by: ymg on December 05, 2015, 10:47:44 PM
I stand corrected !

Tried that before and never succeeded.

I was missing, that you can assign a key to the  whole dialog.

ymg
Title: Re: write DCL title at runtime
Post by: XXL66 on December 06, 2015, 05:08:21 AM
thx for the replies guys, eventually i ended up creating it on the fly because i needed to adjust the width also.
Title: Re: write DCL title at runtime
Post by: roy_043 on December 07, 2015, 01:54:53 PM
Note: In BricsCAD flexible dialogs are possible. Although you cannot set the width programmatically.
Code: [Select]
MyDialog : dialog {
  fixed_height = false;
  fixed_width = false;
...
...
}
Title: Re: write DCL title at runtime
Post by: XXL66 on December 09, 2015, 03:08:27 AM
Thx Roy, BricsCAD is awesome !