Author Topic: DCL code to string  (Read 3971 times)

0 Members and 1 Guest are viewing this topic.

SPDCad

  • Bull Frog
  • Posts: 453
DCL code to string
« on: June 06, 2005, 11:26:58 AM »
Anyone have a lisp that will translate DCL code to a string?
I like to write my dcl code in file.dcl format first.  Then I translate it to a string  when my lisp is complete.
Then I insert the string into my lisp and have my lisp generate the dcl code when executed.
I practice this to keep the number of files to a minimum and to make sure the lisp finds the dcl code and doesn't return an error because the user has not put the dcl code in a search path.

If no lisp is available;
    I am currently writing a lisp to translate the code and I am stuck at
replacing  “  (quote symbol) with  \”.  Current autocad won’t accept  the following code.
Code: [Select]
(setq CHK (vl-string-subst """ "\"" Line)

Any help would be greatly appreciated.
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
DCL code to string
« Reply #1 on: June 06, 2005, 12:02:35 PM »
Some times I write the dcl code to a tmp file then call it.
Code: [Select]


(defun mktemp-dcl (/ tmpf tmpfo)
  (setq tmpf  (vl-filename-mktemp nil nil ".dcl")
        tmpfo (open tmpf "w")
        )
  (write-line
    (strcat
      "diag1 : dialog {
      label = \"Select a program to run\";
      : boxed_column {
      label = \"\";
      :row {
      : button {
      fixed_width = true;
      key = \"button1\";
      label = \"Lisp1\";
      }
      : button {
      fixed_width = true;
      key = \"button2\";
     label = \"Lisp2\";
     }
     : button {
     label = \"Cancel\";
     is_cancel = true;
     key = \"cancel\";
     fixed_width = true;
     }}}}"
      ) ; strcat
    tmpfo
    )
  (close tmpfo)

  tmpf
  )
TheSwamp.org  (serving the CAD community since 2003)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
DCL code to string
« Reply #2 on: June 06, 2005, 12:08:23 PM »
Indeed, I do that in many apps, like the info and axprops utils.

Did you know you don't have to use a dcl extension?

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

mohobrien

  • Guest
DCL code to string
« Reply #3 on: June 06, 2005, 01:27:24 PM »
Kenny has a little tutorial on this here.
http://www.afralisp.com/lisp/dclatt.htm

SPDCad

  • Bull Frog
  • Posts: 453
DCL code to string
« Reply #4 on: June 06, 2005, 02:50:34 PM »
I sorry guys I must have explained what I am looking for wrong. I know how to get AutoCad to make the temporary dcl file and have autocad read it. As explained at the link http://www.afralisp.com/lisp/dclatt.htm. . I wrote a lisp called MAKEDCL years ago that does that.
What I am looking for is a way to take a pre-made dcl file and make it into a string.

ie.  take a file containing

TEST : dialog {
: text { label = "Test"
              key = TXT;
         }
ok_cancel;
}

And turn it  into a string

"TEST : dialog { : text { label = \"Test\" key = TXT; } ok_cancel; }"

that I then feed into the MAKEDCL lisp.

Like I mentioned above I am currently writing a lisp to translate the code from dcl to a string but I am stuck at  replacing “ (quote symbol) with \”.
Currently autocad won’t accept the following code.
Code:
(setq CHK (vl-string-subst """ "\"" Line)


I hope that explanation is a little cleaner….
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

SPDCad

  • Bull Frog
  • Posts: 453
DCL code to string
« Reply #6 on: June 07, 2005, 02:46:07 PM »
Thanks CAB, thats is similar to what i was looking for.
 :)
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs