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

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
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:
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
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

  • Swamp Rat
  • Posts: 812
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.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Lee Mac

  • Seagull
  • Posts: 12904
  • 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

  • Swamp Rat
  • Posts: 812
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.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg