Jump to content

A simple .dcl probblem, Useign a varible


Recommended Posts

Posted

Gday!

All i want in my options to relate to my varibles, so that it will give me 3 buttons of 40 50 60, not "options1" simple, but i carnt work it out.

 

thanks heaps!!

 

;lsp
(defun c:trail ()
 ;done by other equations & input
 (setq bltlength 40)
 (setq bltlenghtop1 50)
 (setq bltlenghtop2 60)
 ;creating diffent options
 (setq Option1 (itoa bltlength))
 (setq Option2 (itoa bltlenghtop1))
 (setq Option3 (itoa bltlenghtop2))
   ;dcl loading
 (setq testload (load_dialog "Length options"))
 (if (null $MYFORM!)
  (setq $myform1 "Option1")
)
 
(cond
 ((new_dialog "myform" testload)
  (set_tile "options" $myform1)
 ; (change-form $mymform1)
  (action_tile "Option1" "(setq bltlenghttot bltlength)")
  (action_tile "Option2" "(setq bltlenghttot bltlenghtop1)")
  (action_tile "Option3" "(setq bltlenghttot bltlenghtop2)")     
  (action_tile "accept" "(setq ok 1) (done_dialog)")
  (action_tile "cancel" "(setq ok 0) (done_dialog)")
  (start_dialog)
  (unload_dialog testload)
  )
  (t (princ "The dcl was not loaded"))
 )
 ;to say what length was selected
 (princ (itoa bltlenghttot))
 (princ)
)
 

 

 

 

;dcl code
myform : dialog {
   label = "Mulitple lengths Avalible" ;
   : boxed_radio_column {
           Key = "options" ;
               label = "What length do you want?";
        : radio_button {key = "Option1" ; label = Option1; }
        : radio_button {key = "Option2" ; label = Option2; }
        : radio_button {key = "Option3" ; label = Option3; }
        }
     ok_cancel;
     }

 

 

 

 

 

 

 

Also, planning an all dcl program, Where in each row, has 4 options of "edit_box"es, with number name qtq mass.

How would i used the take each of the names, which have min 4 numbers to times to get mass etc, when its is maybe 1-100 rows with out making the code 100 times, i hope i explained this understandable

Posted

I don't quite understand. Do you want the DCL labels to be dynamic? If so, the DCL file will have to be remade each time. It isn't that hard to do for small routines. I'll dig up a sample if need be. -David

Posted

Found it

(defun c:dcl-samp (/ id code action output tiles klabel)

;;;PRESET LISP FILE NAME
 (setq lsp_file "DCL-SAMP")

;;;SET THE CODE/VALUE LIST
 (if (null dcl_def)
     (setq dcl_def (list
                         "V3D"
                         "X18"
                         "Y30"
                         "Z30"
                     )))

;;;DYNAMIC LABEL DESCRIPTIONS
;;;USES THE VARIABLE NAME IF NO DECRIPTION
 (setq klabel '(("X" . "X  Width S-S")
                ("Y" . "Y  Depth F-B")
                ("Z" . "Z Height T-B")))

;;;DECRYPT VARIABLE NAMES AND VALUES
 (foreach var (reverse ddcl_def)
   (setq code (strcase (substr var 1 1))
         tiles (cons code tiles))
   (set (read code) (substr var 2)))

;;;MAKE THE DCL FILE
 (make-dcl)

;;;RUN THE DCL BOX
 (setq id (load_dialog lsp_file))
 (new_dialog "dclin" id)
 (foreach var tiles
       (action_tile var (strcat "(setq " var " (get_tile \"" var "\"))")))
 (action_tile "accept" "(done_dialog 1)")
 (action_tile "cancel" "(done_dialog 0)")
 (setq action (start_dialog))
 (unload_dialog id)

;;;WORK WITH THE RESULTS
 (if (> action 0)
     (progn
       (foreach var tiles
              (setq output (cons (strcat var (eval (read var))) output)))
       (prin1 output)))

 (prin1))


;;;MAKE DCL FILES FOR INPUT
;;;klable CONTAINS THE DYNAMIC LABEL DATA
(defun make-dcl (/ wf)
  (setq wf (open (strcat lsp_file ".DCL") "w"))
  (write-line (strcat "dcl_settings : default_dcl_settings { audit_level = 0; }") wf)
  (write-line (strcat "dclin : dialog { label = \"DCL Inputs\" ;") wf)
  (write-line (strcat "  : column {") wf)
  (foreach n tiles
       (write-line (strcat
                    "    : edit_box {key = \"" n "\""
                    " ; label = \""
                    (if (assoc n klabel) (cdr (assoc n klabel)) n)
                    ":\""
                    " ; value = \"" (eval (read n)) "\""
                    " ; edit_width = 25 ;"
                    " mnemonic = \"" n "\" ; }") wf))
  (write-line (strcat "    }") wf)
  (write-line (strcat "  : row { ok_cancel ;}}") wf)
  (close wf)
(prin1))

-David

Posted

Perhaps something to this nature:

 

(defun c:write-dcl  (/ file dclLst)
 (setq    file   (open "myDCL.dcl" "a")
   dclLst (list
        "myform : dialog {"
        "label = \"Multiple lengths Available\";"
        ": boxed_radio_column {"
        "key = \"options\";"
        "label = \"What length do you want?\";"
        (strcat ": radio_button {key = \"Option1\" ; label = " Option1 "; }")
        (strcat ": radio_button {key = \"Option2\" ; label = " Option2 "; }")
        (strcat ": radio_button {key = \"Option3\" ; label = " Option3 "; }}")
        "ok_cancel;}"))
 (mapcar '(lambda (x) (write-line x file)) dclLst)
 (close file)
 (princ))

Posted

Thanks heaps, Ill give it a go at home.

How do you delete a file? Or more so, how do you search if a file exists

?

Havnt looked, but if you know off the top of your head.

 

Thanks again!

Posted
Thanks heaps, Ill give it a go at home.

How do you delete a file? Or more so, how do you search if a file exists

?

Havnt looked, but if you know off the top of your head.

 

Thanks again!

 

You could use (findfile "... filename") to search for files in the search directory.

 

And maybe to delete:

 

(vl-file-delete filename)

 

^^ Be careful with this one! :unsure:

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...