TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Visual DCL Programming => Topic started by: alanjt on July 17, 2008, 09:19:02 PM

Title: dcl edit dialog issue with some text strings...
Post by: alanjt 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
 )
Title: Re: dcl edit dialog issue with some text strings...
Post by: alanjt 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

 )