TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Visual DCL Programming => Topic started by: Grrr1337 on November 24, 2016, 03:12:21 PM

Title: list_box / popup_list DCL temporarily written
Post by: Grrr1337 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:
Title: Re: list_box / popup_list DCL temporarily written
Post by: roy_043 on November 24, 2016, 03:43:03 PM
You have to use "\\n" instead of "\n" (escape the escape character).
Title: Re: list_box / popup_list DCL temporarily written
Post by: Grrr1337 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.
Title: Re: list_box / popup_list DCL temporarily written
Post by: Lee Mac 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 (http://bit.ly/18lFkEv) & here (http://bit.ly/1BMREfO).

Lee
Title: Re: list_box / popup_list DCL temporarily written
Post by: Grrr1337 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 (http://bit.ly/18lFkEv) & here (http://bit.ly/1BMREfO).

Lee
Thank you, Lee! :)

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