Author Topic: list_box / popup_list DCL temporarily written  (Read 120 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Newt
  • Posts: 144
list_box / popup_list DCL temporarily written
« on: November 24, 2016, 03:12:21 pm »
Hi guys,
This is driving me nuts. The following dialog runs without problem as .dcl file:
DCL
Code: [Select]
ACAD_Stuff : dialog
{
: popup_list
{
label = "&Attachment:";
list = "TopLeft\nTopCenter\nTopRight\nMiddleLeft\nMiddleCenter\nMiddleRight\nBottomLeft\nBottomCenter\nBottomRight";
key = "att";
}
: row
{
fixed_width = true;
alignment = centered;
: button {
label = "&Pick Points <";
key = "accept";
is_default = true;
}
: spacer { width = 1; }
cancel_button;
: spacer { width = 1; }
help_button;
}
}
But when I try to transform the same as a list of strings for being temporary written:

Code: [Select]
(defun C:test ( / Lst FpathWithFname fileDCL dcl_id )

(setq Lst
(list
"ACAD_Stuff : dialog"
"{"
": popup_list"
"{"
"label = \"&Attachment:\";"
"list = \"TopLeft\nTopCenter\nTopRight\nMiddleLeft\nMiddleCenter\nMiddleRight\nBottomLeft\nBottomCenter\nBottomRight\";"
"key = \"att\";"
"}"
": row"
"{"
"fixed_width = true;"
"alignment = centered;"
": button {"
"label = \"&Pick Points <\";"
"key = \"accept\";"
" is_default = true;"
"}"
": spacer { width = 1; }"
"cancel_button;"
": spacer { width = 1; }"
"help_button;"
"}"
"}"
); list
); setq Lst

(setq FpathWithFname (vl-filename-mktemp nil nil ".dcl"))
(setq fileDCL (open FpathWithFname "w"))
(foreach x Lst (write-line x fileDCL))
(close fileDCL)
(setq dcl_id (load_dialog FpathWithFname))
(and (not (new_dialog DlgName dcl_id))(exit))

(start_dialog)
(unload_dialog dcl_id)
(vl-file-delete FpathWithFname)
); defun 
I get a bunch of errors such as:
Quote
line 6: newline in string constant
line 7: missing semicolon
line 8: invalid attribute, Symbol "TopRight".
line 8: syntax error. Symbol "TopRight".
This DCL code is not mine - I'm just trying to figure out how to populate a list_box / popup_list inside the DCL code.  :cry:

roy_043

  • Swamp Rat
  • Posts: 1367
  • BricsCAD 16
Re: list_box / popup_list DCL temporarily written
« Reply #1 on: November 24, 2016, 03:43:03 pm »
You have to use "\\n" instead of "\n" (escape the escape character).

Grrr1337

  • Newt
  • Posts: 144
Re: list_box / popup_list DCL temporarily written
« Reply #2 on: November 24, 2016, 04:09:30 pm »
You have to use "\\n" instead of "\n" (escape the escape character).
Thank you Roy, It worked!  :-o
Do you know where to read about this? I'm kinda familiar with \n \t \" but I might miss something.

Lee Mac

  • Seagull
  • Posts: 11467
  • AutoCAD 2015 Windows 7 London, England
Re: list_box / popup_list DCL temporarily written
« Reply #3 on: November 24, 2016, 04:39:24 pm »
Do you know where to read about this? I'm kinda familiar with \n \t \" but I might miss something.

Consider that you require '\n' to appear in the DCL file, therefore, since AutoLISP will interpret '\n' as a newline character, the backslash must be marked as a literal by prefixing it with another backslash.

You can read more about this here & here.

Lee

Grrr1337

  • Newt
  • Posts: 144
Re: list_box / popup_list DCL temporarily written
« Reply #4 on: November 24, 2016, 04:56:09 pm »

Consider that you require '\n' to appear in the DCL file, therefore, since AutoLISP will interpret '\n' as a newline character, the backslash must be marked as a literal by prefixing it with another backslash.

You can read more about this here & here.

Lee
Thank you, Lee! :)

I'm becomming more interested into DCL so I might bring up back to life this forum by asking questions.