Jump to content

Dialog to remember entry


woodman78

Recommended Posts

I am trying to get my dialog box to remember the last thing I entered for both fields. This is what I have but it doesn't work. I had a look at afralisp but I don't see where I'm going wrong. Can anyone help?

 

 
;; local defun by CAB (Charles Alan Butler)
(defun LayerMake_CPO (lyrname Color ltype)
 (if (tblsearch "LAYER" lyrname)
   (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "")
   (command "._Layer" "_Make" lyrname "_Color"
            (if (or (null color)(= Color "")) "_White" Color) lyrname
            "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "")
 )
)
 
(defun C:CPO (/ *error* ang col clr coords dwo elist midp offsetted ofpt osm p1 p2 p3 pline a b c name1 folio1 SUCE SUOM SUSM SUAB SUAD SUCL SUCR)
(setq dcl_id (load_dialog "cpo.dcl"))
    (if (not (new_dialog "cpo" dcl_id))
 (exit)
    );if

(setq SUCE (getvar "cmdecho"))
 (setq SUOM (getvar "orthomode"))
 (setq SUSM (getvar "osmode"))
 (setq SUAB (getvar "angbase"))
 (setq SUAD (getvar "angdir"))
 (setq SUCL (getvar "clayer"))
 (setq SUCR (getvar "cecolor"))

[color=red](set_tile "name" name1)[/color]

(action_tile "name" "(setq name1 $value)")
(action_tile "folio" "(setq folio1 $value)")
;(action_tile "accept" (val1))

(start_dialog)
(unload_dialog dcl_id)
 (setq a (strcat "CCC_CPO_"folio1"_"name1"_Grey_Hatch")
       b (strcat "CCC_CPO_"folio1"_"name1"_Outline_Red")
       c (strcat "CCC_CPO_"folio1"_"name1"_Outline_Black")
       d (strcat "CCC_CPO_"folio1"_"name1"_Leader"))
(defun *error* (msg)
 (if
   (vl-position
     msg
     '("console break"
"Function cancelled"
"quit / exit abort"
)
     )
    (princ "Error!")
    (princ msg)
    )
 (if osm (setvar "osmode" osm))
 (if clr (setvar "clayer" clr))
 (if col (setvar "cecolor" col))
 (if dwo (setvar "draworderctl" dwo))
 (command "._undo" "_END")
 )
(Alert "Remember to draw the plot outline in an ANTI-CLOCKWISE direction.")
(command "_.insert" "CCC_CPO_Leader_Styles=" nil)
(command "_.purge" "_b" "CCC_CPO_Leader_Styles" "_n")
 (setq osm (getvar "osmode"))  
 (setq col (getvar "cecolor"))
 (setq clr (getvar "clayer"))
 (setq dwo (getvar "draworderctl"))
 (command "._undo" "_BE")
 (setvar "osmode" 1)
 (setvar "cecolor" "bylayer")
 (setvar "HPORIGINMODE" 5)
 (LayerMake_CPO a "254" "Continuous")
 (LayerMake_CPO b "1" "Continuous")
 (LayerMake_CPO c "7" "Continuous")
 (LayerMake_CPO d "7" "Continuous")
(setvar "clayer" c)  
(command "._pline")
(while (= 1 (logand 1 (getvar "cmdactive")))
(command pause))
 (setq pline (entlast)
elist (entget pline)
)
(setq elist (entmod (subst (cons 70 1)(assoc 70 elist)elist)));<--close pline
(entmod (subst (cons 43 0)(assoc 43 elist)elist));<--set line width to zero
(setvar "draworderctl" 3)  
(command "_.draworder" pline "" "_F");<--set pline's draw order to front  
(setq coords (vl-remove-if (function not)
  (mapcar (function (lambda (x)
        (if (= 10 (car x))(cdr x))))
   elist))
)
(setq p3 (caddr coords)
     p1 (car coords)
     ang (angle p1 p3)
     ofpt (polar p3 ang 1.0)
     )
(setvar "clayer" b)
(command "._offset" 0.5 pline ofpt "")
 (setq offsetted (entlast)
 elist (entget offsetted)
)
;(command "chprop" offsetted "LA" b "")
;(command "_change" offsetted ""  "p" "layer" b "color" "bylayer" "")
(if (assoc 62 elist)
(setq elist (subst (cons 62 1)(assoc 62 elist) elist ))
(setq elist (append elist (list '(62 . 1))))
)
(entmod elist)
(command "._pedit" offsetted "_W" 1.0 "")
(command "_.draworder" offsetted "" "_B");<--set pline's draw order to back  
(setq coords (vl-remove-if (function not)
  (mapcar (function (lambda (x)
        (if (= 10 (car x))(cdr x))))
   elist))
)
 (setq p2 (car coords)
midp (mapcar (function (lambda( a b)(/ (+ a b) 2)))
      p1 p2)
)
 (setvar "clayer" a)
 (setvar "hpname" "SOLID")
 (command "-hatch" "S" pline "" "")
 ;(while (> (getvar "cmdactive") 0)
   ;(command "\\") ;<- The Pause symbol will not pause the command. Backslash used instead. 
 
 (setvar "hpname" ".")
 
 (setvar "clayer" d)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (if (null (tblsearch "STYLE" "CCC_CPO_Leader"))
  (progn
      (entmake
         (list
           (cons 0 "STYLE")
           (cons 100 "AcDbSymbolTableRecord")
           (cons 100 "AcDbTextStyleTableRecord")
           (cons 2 "CCC_Note_Numbers")
           (cons 3 "Verdana.ttf")
           (cons 40 0)
   (cons 74 1) ;Bold
           (cons 70 0)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setvar "textstyle" "CCC_CPO_Leader")
(setvar "CMLEADERSTYLE" "CCC_CPO_Leader")
  (setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(command "_.mleader")
 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (setvar "clayer"    SUCL)
 (setvar "cecolor"    SUCR)
(princ) 
)

 

and the dcl for it:

cpo: dialog
{label = "CPO Layer Creation";
: edit_box 
            {
label = "Enter landowner name :";
key = "name";
alignment = centered;
edit_limit = 30;
edit_width = 30;
}

: edit_box
{
label = "Enter parcel number :";
key = "folio";
alignment = centered;
edit_limit = 10;
edit_width = 30;
}

: button 
{
key = "accept";
label = "OK";
is_default = true;
fixed_width = true;
alignment = centered;
}

: errtile
{
width = 34;
}
}

 

Thanks.

Link to comment
Share on other sites

Guest kruuger

you try to set control but your variable is nil

try this:

(if *name1*
   (set_tile "name" *name1*)
   (set_tile "name" "Default")
 )

you need to save your variable as a global *name1* not local.

(action_tile "name" "(setq *name1* $value)")

you can also save it to registry

 

kruuger

Link to comment
Share on other sites

Thanks kruuger. that did the job.

 

When you say save it to the registry do you mean as "appdata".

 

Does storing large amounts of data in the registry slow the machine?

Link to comment
Share on other sites

I prefer to save to a cfg file, just to make for easier removal, however, storing small amounts of data in the registry shouldn't be too much of a problem - the drawback is that the user has to dig through the registry to remove the unwanted keys (which can be dangerous if they delete the wrong key).

 

If you wish to go the registry route, you can either use setenv/getenv which stores the keys under:

 

(strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\FixedProfile\\General")

 

Or use vl-registry-write to write to your own location - however, be very careful where path/key naming is concerned.

Link to comment
Share on other sites

Guest kruuger
Thanks kruuger. that did the job.

 

When you say save it to the registry do you mean as "appdata".

 

Does storing large amounts of data in the registry slow the machine?

i usually save to registry data like: program version, dialog position, some dialog control settings etc.

(vl-registry-write "HKEY_CURRENT_USER\\Software\\Stuff\\Program1" "Version" "1.00")
(vl-registry-write "HKEY_CURRENT_USER\\Software\\Stuff\\Program2" "Language" "EN")

(vl-registry-read "HKEY_CURRENT_USER\\Software\\Stuff\\Program1" 
"Version")

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