Author Topic: dcl edit dialog issue with some text strings...  (Read 7995 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
dcl edit dialog issue with some text strings...
« on: July 17, 2008, 09:19:02 PM »
i found this digging around in the lilly pond a while back (it's either mark or john's) and was hoping to use it or at least build my own using this as an example. the problem is, i've noticed if the string that is to be the text displayed (to edit) in the dialog has periods or hyphens, etc. in them, the dcl freaks out and doesn't work (just letters and it's fine). i was wondering if anyone might have some insight into what's going wrong and if it's possible to rectify the issue?

here's the code:

mark and/or john, i hope you don't mind me posting this, if so, i'll quickly remove it.

Code: [Select]
(defun GetString-dlg (str / dcl_id fn fo)
  (setq fn (vl-filename-mktemp "" "" ".dcl"))
  (setq fo (open fn "w"))
  (setq ValueStr (strcat "value = " str ";"))
  (write-line "stringdlg : dialog {
              label = \"Enter String\";" fo)
  (write-line ": edit_box {
              label = \"\";
              edit_width = 30;
              key = \"stringdlg\";
              is_default = true; " fo)
  (write-line ValueStr fo)
  (write-line "}" fo)
  (write-line ": row {
              alignment   = centered;
              fixed_width = true;
               : button {
               label      = \"OK\";
               key        = \"dcl_accept\";
               width      = 10;
               allow_accept = true;
             }
           }
         }" fo)
   (close fo)
   (setq dcl_id (load_dialog fn))
   (new_dialog "stringdlg" dcl_id)
   (action_tile "stringdlg" "(setq str $value)(done_dialog)")
   (start_dialog)
   (unload_dialog dcl_id)
  str
 )
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: dcl edit dialog issue with some text strings...
« Reply #1 on: July 29, 2008, 10:09:51 PM »
i figured it out the next day, thought i'd post it for anyone down the line. i just had to add some \" in the strcat for the value.
here's the updated code:
Code: [Select]
(defun GetString-dlg (str / dcl_id fn fo)

  (setq fn (vl-filename-mktemp "" "" ".dcl"))

  (setq fo (open fn "w"))

  (setq ValueStr (strcat "value = \"" str "\";"))

  (write-line "stringdlg : dialog {

              label = \"Enter String\";" fo)

  (write-line ": edit_box {

              label = \"\";

              edit_width = 30;

              key = \"stringdlg\";

              is_default = true; " fo)

  (write-line ValueStr fo)

  (write-line "}" fo)

  (write-line ": row {

              alignment   = centered;

              fixed_width = true;

               : button {

               label      = \"OK\";

               key        = \"dcl_accept\";

               width      = 10;

               allow_accept = true;

             }

           }

         }" fo)

   (close fo)

   (setq dcl_id (load_dialog fn))

   (new_dialog "stringdlg" dcl_id)

   (action_tile "stringdlg" "(setq str $value)(done_dialog)")

   (start_dialog)

   (unload_dialog dcl_id)

   (vl-file-delete fn)

  str

 )
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox