Author Topic: write DCL title at runtime  (Read 9451 times)

0 Members and 1 Guest are viewing this topic.

XXL66

  • Newt
  • Posts: 99
write DCL title at runtime
« 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 !

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: write DCL title at runtime
« Reply #1 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

« Last Edit: December 05, 2015, 03:32:17 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ur_naz

  • Newt
  • Posts: 68
  • Made in Ukraine
Re: write DCL title at runtime
« Reply #2 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")

ymg

  • Guest
Re: write DCL title at runtime
« Reply #3 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
« Last Edit: December 05, 2015, 12:18:47 PM by ymg »

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: write DCL title at runtime
« Reply #4 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.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: write DCL title at runtime
« Reply #5 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.


ymg

  • Guest
Re: write DCL title at runtime
« Reply #6 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
« Last Edit: December 05, 2015, 11:41:07 PM by ymg »

XXL66

  • Newt
  • Posts: 99
Re: write DCL title at runtime
« Reply #7 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.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: write DCL title at runtime
« Reply #8 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;
...
...
}

XXL66

  • Newt
  • Posts: 99
Re: write DCL title at runtime
« Reply #9 on: December 09, 2015, 03:08:27 AM »
Thx Roy, BricsCAD is awesome !