Jump to content

Problem in DCL


rdx

Recommended Posts

Dear Sir,

What is problem in this DCL CODE 

(setq RX (OPEN (setq LSDCL (VL-FILENAME-MKTEMP "tmp" "" ".dcl")) "w"))
(WRITE-LINE "tccz:dialog{" RX)
(WRITE-LINE "   label=\"Layer Operations\";" RX)
(WRITE-LINE "   :row{" RX)
(WRITE-LINE "        :button{label=\"object select\";key=\"accept\";is_default=true;fixed_width=true;width=4;}" RX)
(WRITE-LINE "        :button{label=\"Dim Select\";key=\"notuxian\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "	}" RX)
(WRITE-LINE "   :row{" RX)
(WRITE-LINE "        :button{label=\"Isolate Select\";key=\"geli\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "        :button{label=\"Close Select\";key=\"nogeli\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "	}" RX)
(WRITE-LINE "   :row{" RX)
(WRITE-LINE "        :button{label=\"Lock Select\";key=\"suoding\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "        :button{label=\"Lock Unselect\";key=\"nosuoding\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "	}" RX)
(WRITE-LINE "   :row{" RX)
(WRITE-LINE "        :button{label=\"Freeze Select\";key=\"dongjie\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "        :button{label=\"Freeze Unselect\";key=\"nodongjie\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "	}" RX)
(WRITE-LINE "   :row{" RX)
(WRITE-LINE "        :text{value=\"when the command is first executed\";is_enabled=flash;\\n fixed_width=true;width=29;fixed_height=true;height=0;}" RX)
(WRITE-LINE "	}" RX)
(WRITE-LINE "   :row{" RX)
(WRITE-LINE "        :button{label=\"Color uniformity\";key=\"bylayer\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "        :button{label=\"Restore\";key=\"huifu\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "	}" RX)
(WRITE-LINE "   :row{" RX)
(WRITE-LINE "        :button{label=\"Layer Management\";key=\"state\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "        :button{label=\"cancel\";key=\"cancel\";is_cancel=true;fixed_width=true;width=14;\\n fixed_height=true;height=1;is_enabled=true;is_flash=true;}" RX)
(WRITE-LINE "	}" RX)
(WRITE-LINE "        :toggle{label=\"Continue last status\";key=\"continu\";fixed_width=true;width=4;}" RX)
(WRITE-LINE "	}" RX)
(CLOSE RX)

 

Screenshot 2024-07-12 112159.jpg

Edited by rdx
Link to comment
Share on other sites

also this: is_enabled=flash;
is_enabled needs Boolean, so true or false.


what is is_flash=true;?

Edited by EnM4st3r
  • Thanks 1
Link to comment
Share on other sites

7 hours ago, EnM4st3r said:

what are those two \\n?

 

embedded newline? so the code shows up on two lines? Just a guess

 

Hard to make heads or tails of this. Why write code to write code? Why re-open the same file for every line? Is it for portability?

 

What error is the OP getting that is causing the problem?

Link to comment
Share on other sites

to get you started 

 

;;; written for rdx 2024-07-12

(defun c:rdx ( / dcl-fp dcl-fn dcl-id continu)
  (vl-load-com)
  (rdx_write_dialog)
  (rdx_start_dialog)
  (princ (strcat "\nValue of continue last selection : " (vl-princ-to-string continu)))
  (princ)
)


(defun rdx_write_dialog ( )
  (if (and (setq dcl-fn (vl-filename-mktemp "tmp" "" ".dcl")) (setq dcl-fp (open dcl-fn "w")))
    (mapcar '(lambda (x)(write-line x dcl-fp))
            (list
              "tccz : dialog {"
              "   label=\"Layer Operations\";"
              "   :row{"
              "        :button{label=\"object select\";key=\"object_select\";is_default=true;fixed_width=true;width=4;}"
              "        :button{label=\"Dim Select\";key=\"notuxian\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :button{label=\"Isolate Select\";key=\"geli\";fixed_width=true;width=4;}"
              "        :button{label=\"Close Select\";key=\"nogeli\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :button{label=\"Lock Select\";key=\"suoding\";fixed_width=true;width=4;}"
              "        :button{label=\"Lock Unselect\";key=\"nosuoding\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :button{label=\"Freeze Select\";key=\"dongjie\";fixed_width=true;width=4;}"
              "        :button{label=\"Freeze Unselect\";key=\"nodongjie\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :text{value=\"when the command is first executed\";is_enabled=true;fixed_width=true;width=29;fixed_height=true;height=0;}"
              "	}"
              "   :row{"
              "        :button{label=\"Color uniformity\";key=\"bylayer\";fixed_width=true;width=4;}"
              "        :button{label=\"Restore\";key=\"huifu\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :button{label=\"Layer Management\";key=\"state\";fixed_width=true;width=4;}"
              "        :button{label=\"cancel\";key=\"cancel\";is_cancel=true;fixed_width=true;width=14;fixed_height=true;height=1;is_enabled=true;}"
              "	}"
              "        :toggle{label=\"Continue last status\";key=\"continu\";fixed_width=true;width=4;}"
              "	}"
             )
    )
  )
  (if dcl-fp (progn (close dcl-fp)(gc)))
)

(defun rdx_start_dialog ( / rtn )
  (if (and (< 0 (setq dcl-id (load_dialog dcl-fn))) (new_dialog "tccz" dcl-id))
    (progn
      (action_tile "cancel" "(done_dialog 0)")
      (action_tile "accept" "(done_dialog 1)")
      (action_tile "object_select" "(alert \"object select\")(done_dialog 2)")
      (action_tile "notuxian" "(alert \"Dim Select\")(done_dialog 3)")
      (action_tile "geli" "(alert \"Isolate Select\")(done_dialog 4)")
      (action_tile "nogeli" "(alert \"Close Select\")(done_dialog 5)")
      (action_tile "suoding" "(alert \"Lock Select\")(done_dialog 6)")
      (action_tile "nosuoding" "(alert \"Lock Unselect\")(done_dialog 7)")
      (action_tile "dongjie" "(alert \"Freeze Select\")(done_dialog 8)")
      (action_tile "nodongjie" "(alert \"Freeze Unselect\")(done_dialog 9)")
      (action_tile "bylayer" "(alert \"Color uniformity\")(done_dialog 10)")
      (action_tile "huifu" "(alert \"Restore\")(done_dialog 11)")
      (action_tile "state" "(alert \"Layer Management\")(done_dialog 12)")
      (action_tile "continu" "(setq continu $value)")
      (setq rtn (start_dialog))
      (unload_dialog dcl-id)
      (vl-file-delete dcl-fn)
    )
    (princ "\nUnable to start dialog")
  )
  (if (null continu)(setq continu "0"))
  (cond
    ((= rtn  0) (princ "\nYou clicked on cancel"))
    ((= rtn  1) (princ "\nYou clicked on ok"))
    ((= rtn  2) (object_select))
    ((= rtn  3) (notuxian))
    ((= rtn  4) (geli))
    ((= rtn  5) (nogeli))
    ((= rtn  6) (suoding))
    ((= rtn  7) (nosuoding))
    ((= rtn  8) (dongjie))
    ((= rtn  9) (nodongjie))
    ((= rtn 10) (bylayer))
    ((= rtn 11) (huifu))
    ((= rtn 12) (state))
  )
)

(defun object_select ()(alert "under construction - object_select"))
(defun notuxian ()(alert "under construction - notuxian"))
(defun geli ()(alert "under construction - geli"))
(defun nogeli ()(alert "under construction - nogeli"))
(defun suoding ()(alert "under construction - suoding"))
(defun nosuoding ()(alert "under construction - nosuoding"))
(defun dongjie ()(alert "under construction - dongjie"))
(defun nodongjie ()(alert "under construction - nodongjie"))
(defun bylayer ()(alert "under construction - bylayer"))
(defun huifu ()(alert "under construction - huifu"))
(defun state ()(alert "under construction - state"))
  

 

alternative for your dcl code :

(defun rdx_write_dialog ( )
  (if (and (setq dcl-fn (vl-filename-mktemp "tmp" "" ".dcl")) (setq dcl-fp (open dcl-fn "w")))
    (mapcar '(lambda (x)(write-line x dcl-fp))
      (list "tccz : dialog {label=\"Layer Operations\";"
            ":boxed_row {label=\"Select layer operation : \";"
              ":column {:bt {label=\"Object Select\";key=\"object_select\";}:bt {label=\"Isolate Select\";key=\"geli\";}"
                       ":bt {label=\"Lock Select\";key=\"suoding\";}:bt {label=\"Freeze Select\";key=\"dongjie\";}}"
              ":column {:bt {label=\"Dim Select\";key=\"notuxian\";}:bt {label=\"Close Select\";key=\"nogeli\";}"
                       ":bt {label=\"Lock Unselect\";key=\"nosuoding\";}:bt {label=\"Freeze Unselect\";key=\"nodongjie\";}}}"
            "spacer;"
            ":boxed_row {label=\"When the command is first executed : \";"
              ":column {:bt {label=\"Layer Management\";key=\"state\";}:bt {label=\"Restore\";key=\"huifu\";}}"
              ":column {:bt {label=\"Color Uniformity\";key=\"bylayer\";}:bt {label=\"Future\";key=\"future\";}}}"
            ":toggle {label=\"Continue last status\";key=\"continu\";}spacer;ok_cancel;}"
            "bt :button {width=26;fixed_width=true;}"
      )
    )
  )
  (if dcl-fp (progn (close dcl-fp)(gc)))
)

 

🐉

Edited by rlx
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

On 7/12/2024 at 11:24 PM, rlx said:

to get you started 

 

;;; written for rdx 2024-07-12

(defun c:rdx ( / dcl-fp dcl-fn dcl-id continu)
  (vl-load-com)
  (rdx_write_dialog)
  (rdx_start_dialog)
  (princ (strcat "\nValue of continue last selection : " (vl-princ-to-string continu)))
  (princ)
)


(defun rdx_write_dialog ( )
  (if (and (setq dcl-fn (vl-filename-mktemp "tmp" "" ".dcl")) (setq dcl-fp (open dcl-fn "w")))
    (mapcar '(lambda (x)(write-line x dcl-fp))
            (list
              "tccz : dialog {"
              "   label=\"Layer Operations\";"
              "   :row{"
              "        :button{label=\"object select\";key=\"object_select\";is_default=true;fixed_width=true;width=4;}"
              "        :button{label=\"Dim Select\";key=\"notuxian\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :button{label=\"Isolate Select\";key=\"geli\";fixed_width=true;width=4;}"
              "        :button{label=\"Close Select\";key=\"nogeli\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :button{label=\"Lock Select\";key=\"suoding\";fixed_width=true;width=4;}"
              "        :button{label=\"Lock Unselect\";key=\"nosuoding\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :button{label=\"Freeze Select\";key=\"dongjie\";fixed_width=true;width=4;}"
              "        :button{label=\"Freeze Unselect\";key=\"nodongjie\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :text{value=\"when the command is first executed\";is_enabled=true;fixed_width=true;width=29;fixed_height=true;height=0;}"
              "	}"
              "   :row{"
              "        :button{label=\"Color uniformity\";key=\"bylayer\";fixed_width=true;width=4;}"
              "        :button{label=\"Restore\";key=\"huifu\";fixed_width=true;width=4;}"
              "	}"
              "   :row{"
              "        :button{label=\"Layer Management\";key=\"state\";fixed_width=true;width=4;}"
              "        :button{label=\"cancel\";key=\"cancel\";is_cancel=true;fixed_width=true;width=14;fixed_height=true;height=1;is_enabled=true;}"
              "	}"
              "        :toggle{label=\"Continue last status\";key=\"continu\";fixed_width=true;width=4;}"
              "	}"
             )
    )
  )
  (if dcl-fp (progn (close dcl-fp)(gc)))
)

(defun rdx_start_dialog ( / rtn )
  (if (and (< 0 (setq dcl-id (load_dialog dcl-fn))) (new_dialog "tccz" dcl-id))
    (progn
      (action_tile "cancel" "(done_dialog 0)")
      (action_tile "accept" "(done_dialog 1)")
      (action_tile "object_select" "(alert \"object select\")(done_dialog 2)")
      (action_tile "notuxian" "(alert \"Dim Select\")(done_dialog 3)")
      (action_tile "geli" "(alert \"Isolate Select\")(done_dialog 4)")
      (action_tile "nogeli" "(alert \"Close Select\")(done_dialog 5)")
      (action_tile "suoding" "(alert \"Lock Select\")(done_dialog 6)")
      (action_tile "nosuoding" "(alert \"Lock Unselect\")(done_dialog 7)")
      (action_tile "dongjie" "(alert \"Freeze Select\")(done_dialog 8)")
      (action_tile "nodongjie" "(alert \"Freeze Unselect\")(done_dialog 9)")
      (action_tile "bylayer" "(alert \"Color uniformity\")(done_dialog 10)")
      (action_tile "huifu" "(alert \"Restore\")(done_dialog 11)")
      (action_tile "state" "(alert \"Layer Management\")(done_dialog 12)")
      (action_tile "continu" "(setq continu $value)")
      (setq rtn (start_dialog))
      (unload_dialog dcl-id)
      (vl-file-delete dcl-fn)
    )
    (princ "\nUnable to start dialog")
  )
  (if (null continu)(setq continu "0"))
  (cond
    ((= rtn  0) (princ "\nYou clicked on cancel"))
    ((= rtn  1) (princ "\nYou clicked on ok"))
    ((= rtn  2) (object_select))
    ((= rtn  3) (notuxian))
    ((= rtn  4) (geli))
    ((= rtn  5) (nogeli))
    ((= rtn  6) (suoding))
    ((= rtn  7) (nosuoding))
    ((= rtn  8) (dongjie))
    ((= rtn  9) (nodongjie))
    ((= rtn 10) (bylayer))
    ((= rtn 11) (huifu))
    ((= rtn 12) (state))
  )
)

(defun object_select ()(alert "under construction - object_select"))
(defun notuxian ()(alert "under construction - notuxian"))
(defun geli ()(alert "under construction - geli"))
(defun nogeli ()(alert "under construction - nogeli"))
(defun suoding ()(alert "under construction - suoding"))
(defun nosuoding ()(alert "under construction - nosuoding"))
(defun dongjie ()(alert "under construction - dongjie"))
(defun nodongjie ()(alert "under construction - nodongjie"))
(defun bylayer ()(alert "under construction - bylayer"))
(defun huifu ()(alert "under construction - huifu"))
(defun state ()(alert "under construction - state"))
  

 

alternative for your dcl code :

(defun rdx_write_dialog ( )
  (if (and (setq dcl-fn (vl-filename-mktemp "tmp" "" ".dcl")) (setq dcl-fp (open dcl-fn "w")))
    (mapcar '(lambda (x)(write-line x dcl-fp))
      (list "tccz : dialog {label=\"Layer Operations\";"
            ":boxed_row {label=\"Select layer operation : \";"
              ":column {:bt {label=\"Object Select\";key=\"object_select\";}:bt {label=\"Isolate Select\";key=\"geli\";}"
                       ":bt {label=\"Lock Select\";key=\"suoding\";}:bt {label=\"Freeze Select\";key=\"dongjie\";}}"
              ":column {:bt {label=\"Dim Select\";key=\"notuxian\";}:bt {label=\"Close Select\";key=\"nogeli\";}"
                       ":bt {label=\"Lock Unselect\";key=\"nosuoding\";}:bt {label=\"Freeze Unselect\";key=\"nodongjie\";}}}"
            "spacer;"
            ":boxed_row {label=\"When the command is first executed : \";"
              ":column {:bt {label=\"Layer Management\";key=\"state\";}:bt {label=\"Restore\";key=\"huifu\";}}"
              ":column {:bt {label=\"Color Uniformity\";key=\"bylayer\";}:bt {label=\"Future\";key=\"future\";}}}"
            ":toggle {label=\"Continue last status\";key=\"continu\";}spacer;ok_cancel;}"
            "bt :button {width=26;fixed_width=true;}"
      )
    )
  )
  (if dcl-fp (progn (close dcl-fp)(gc)))
)

 

🐉

Dear Sir..

Thank you very much .. i am fan of you .. 

  • Thanks 1
Link to comment
Share on other sites

On 7/12/2024 at 3:23 PM, CyberAngel said:

embedded newline? so the code shows up on two lines? Just a guess

Yes could be, but wouldnt you just use "\n" for it? i mean not a double backslash? not sure.

Either way i think its useless since you can just keep the rest of the text on the same line.

  • Thanks 1
Link to comment
Share on other sites

\\n because a single \ is a control character in a string, to write a single \ to the text file you need to add \ (control character) and \ (character you want to use) - special case for \ that you have to specify you want to use it as a \

  • Agree 2
Link to comment
Share on other sites

yes, but i mean wouldnt that just write \n to the dcl file? having a random \n in da dcl file doesnt make sense so i dont see how it would write a new line.. or im understanding something wrong here

Link to comment
Share on other sites

for example in this line i would see the \\n as wrong. I would just remove it.

 

(WRITE-LINE "        :text{value=\"when the command is first executed\";is_enabled=flash;\\n fixed_width=true;width=29;fixed_height=true;height=0;}" RX)

 

Edited by EnM4st3r
Link to comment
Share on other sites

1 hour ago, EnM4st3r said:

for example in this line i would see the \\n as wrong. I would just remove it.

 

Either of these options still work. What your CAD software is looking for is the correct syntax and format with { } like ( ) in lisp. you can write lisp/dcl with one word per line or all on one line as long as the ( ) & { } match up. wouldn't be easy to read but would work. if it works how can it be wrong? its more like personal preference. so if you don't want them broken up into multiple lines take out the //n. or like in my third example add it after each ;

 

:row {
        :text { value="when the command is first executed"; is_enabled=flash; fixed_width=true; width=29; fixed_height=true; height=0; }
	}

:row {
        :text { value="when the command is first executed"; is_enabled=flash; 
        fixed_width=true; width=29; fixed_height=true; height=0; }
	}
:row {
        :text { value="when the command is first executed"; 
        is_enabled=flash; 
        fixed_width=true; 
        width=29; 
        fixed_height=true; 
        height=0; }
	}

 

 

  • Like 1
Link to comment
Share on other sites

It is not necessary but it is not a problem either as MHUPP says, and like him if I wanted a new line in the DCL I'd create a new "Write Line" line - so long as everything is in pairs, opened and closed it doesn't matter too much. 

 

My personal preference is if it is a permanent DCL I'd be more picky for readability and future upgrades in the DCL file, or as above, on the fly, I'd be more picky about readability and future upgrades in the code that makes the DCL. Lots of lines and space in permanent DCL files, nothing excess like the "\\n" above in on the fly code, it just gets in the way there.

Link to comment
Share on other sites

6 hours ago, mhupp said:

if it works how can it be wrong? its more like personal preference.

 

 

If there's any possibility that someone else will need to maintain it, it should be readable, not just functional. And in six months you yourself may not remember how it works.

Link to comment
Share on other sites

it does not work tough..
 @mhupp your examples do work, and i do not say otherwise, but im still saying that "\\n" does not work and is wrong.

"\n" would write a new line, with "\\n" however the "\" will be interpreted as a normal string character and it will not write the rest to a new line it will instead write literally "\n" to the file.

in the first code of this thread op asked why his code is not working, in that code i pointed out those 2 "\\n" parts so he can check if that is correct. If you write his code to a file and open the file this is what the .dcl looks like:
 

tccz:dialog{
   label="Layer Operations";
   :row{
        :button{label="object select";key="accept";is_default=true;fixed_width=true;width=4;}
        :button{label="Dim Select";key="notuxian";fixed_width=true;width=4;}
	}
   :row{
        :button{label="Isolate Select";key="geli";fixed_width=true;width=4;}
        :button{label="Close Select";key="nogeli";fixed_width=true;width=4;}
	}
   :row{
        :button{label="Lock Select";key="suoding";fixed_width=true;width=4;}
        :button{label="Lock Unselect";key="nosuoding";fixed_width=true;width=4;}
	}
   :row{
        :button{label="Freeze Select";key="dongjie";fixed_width=true;width=4;}
        :button{label="Freeze Unselect";key="nodongjie";fixed_width=true;width=4;}
	}
   :row{
        :text{value="when the command is first executed";is_enabled=flash;\n fixed_width=true;width=29;fixed_height=true;height=0;}
	}
   :row{
        :button{label="Color uniformity";key="bylayer";fixed_width=true;width=4;}
        :button{label="Restore";key="huifu";fixed_width=true;width=4;}
	}
   :row{
        :button{label="Layer Management";key="state";fixed_width=true;width=4;}
        :button{label="cancel";key="cancel";is_cancel=true;fixed_width=true;width=14;\n fixed_height=true;height=1;is_enabled=true;is_flash=true;}
	}
        :toggle{label="Continue last status";key="continu";fixed_width=true;width=4;}
	}


As you can see in line 20 and 28 there are the \n parts.
(after fixing that flash stuff, still dont know what that is) When running the dcl you will continue to get a error in Line 20 until you remove that \n, same with line 28.
After removing all the "\\n" aswell as that "flash" stuff the dcl does show up. 

  • Like 1
Link to comment
Share on other sites

the \\n and flash were just a mistake, get over it haha. only reason you would use \n in a string would be in an alert string or when you write to a file using princ instead of write-line. 

 

ps disabled all email alerts for now because of workload 🥴😓

Link to comment
Share on other sites

36 minutes ago, rlx said:

the \\n and flash were just a mistake, get over it haha.

 

bro thats what I said fom the beginning, but somehow everyone acted as if the \\n is correct.. thats the only reason this even started and why i got confused

Link to comment
Share on other sites

OP sent me a private message with his (broken) code so far and there I also found this code "\\nbladiebla". This would only produce "\nbladiebla".

Only if you would want to princ 2 lines , on the first line a \ and the second line bladiebla you would use (princ "\\\nbladibla")

But especially in the context of OP's program this makes no sense at all , so whether it's a typo or a search and replace horribly go wrong , lets purge this from our brain cells , preferably with lots of beer (or babymilk , whatever) and for now don't PM me unless for dirty pictures or something because I don't have the time to be your private dancer (Tina Turner) , its 01.30 am and I have to present a new app (automatic instrument loop checker , dbx) at 08.30 am and it's not finished yet so this is gonna be an all nighter , bummers 🥴 😱 💩

  • Funny 1
  • Agree 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...