TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: SPDCad on June 06, 2005, 11:26:58 AM

Title: DCL code to string
Post by: SPDCad 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.
Title: DCL code to string
Post by: Mark 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
  )
Title: DCL code to string
Post by: MP 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?

:)
Title: DCL code to string
Post by: mohobrien on June 06, 2005, 01:27:24 PM
Kenny has a little tutorial on this here.
http://www.afralisp.com/lisp/dclatt.htm
Title: DCL code to string
Post by: SPDCad 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….
Title: DCL code to string
Post by: CAB on June 06, 2005, 03:53:40 PM
http://www.theswamp.org/phpBB2/viewtopic.php?t=1706&highlight=dcl2lisp
Title: DCL code to string
Post by: SPDCad on June 07, 2005, 02:46:07 PM
Thanks CAB, thats is similar to what i was looking for.
 :)