jmerch Posted January 25, 2012 Posted January 25, 2012 I have created a couple simple DCL boxes for users to enter information. Now I want to make one that is just a pulldown menu and the items in the list are files from a directory (that way it's always updated automatically). then execute that file when the user clicks on it. So think of "file" as .lsp for example. The user would find it in the pulldown and click on it and it will execute it. any help would be appreciated. Also, is there any online tutorials that teach DCL and/or documentation that lists every function in DCL and what it does? Thanks! Quote
BlackBox Posted January 25, 2012 Posted January 25, 2012 I should learn DCL one of these days .... Here's a direct link to the Working with Programmable Dialog Boxes chapter of the AutoLISP Developer's Guide. Also I know Lee's written some excellent tutorials. HTH Quote
MSasu Posted January 25, 2012 Posted January 25, 2012 Basically, there are some steps you may follow: Create the list of LSP files in your path: (setq MyToolsList (vl-directory-files MyToolsPath "*.LSP" 1)) Load the list of available tools in interface: (start_list DCLListBox) (mapcar 'add_list MyToolsList) (end_list) Get the current selection when user press the OK button: (action_tile "accept" "(setq ToolToRun (get_tile \"DCLListBox\"))(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") After the dialog is closed with OK call the tool chosed by user: (if (= (getvar "DIASTAT") 1) (load (strcat MyToolsPath (nth (atoi ToolToRun) MyToolsList))) ) Regards, Mircea Quote
LibertyOne Posted January 25, 2012 Posted January 25, 2012 jmerch - he who googles, finds... Now I'm going to give all y'all a great tip for finding anything on google. You want good resources on DCL programming. Not just one but a multiple of resources. Looking for "DCL" is a good start, but that just might give you the "Department of Correctional Loafers", which we really don't need. "DCL" is an abbreviation of "Dialog Control Language". Use that in your search. And we're looking for documents, right? Perhaps a paperless form of a document? A so called PDF? Type this in Google's search box: filetype:PDF "dialog control language" This should give you some good reading material. Another good search tactic I use is Google Images. Search for "dialog control language" in google images and see what comes up. Follow the images to a website that is describing how to write them. Hope these two tips help you with your search. Quote
jmerch Posted January 25, 2012 Author Posted January 25, 2012 I do use google searches quite a bit and use most of your tips (I didn't know you could specify filetypes in searches like that), before I ever go to asking the question on posts. DCL actually pulls up more results for Disney Cruise Line Thanks for the tip. Quote
BlackBox Posted January 25, 2012 Posted January 25, 2012 Google fan here. FTFY: Type this in Google's search box: Consider the results from this search string (linked): [url="http://lmgtfy.com/?q=filetype%3APDF+%22dialog+control+language%22"]filetype:PDF "dialog control language"[/url] This should give you some good reading material. Quote
LibertyOne Posted January 25, 2012 Posted January 25, 2012 DCL actually pulls up more results for Disney Cruise Line True, true Quote
BIGAL Posted January 26, 2012 Posted January 26, 2012 Not a bad idea using a dcl to pick a lisp for my five cents worth we have all our lisps in a pull down menu they are listed in alphabetical order grouped A-D E-H etc with sub menus and the description is not necessarily the name of the lisp. Thats the only drawback I see in using lisp file names. The advantage also I can go straight to a z lisp without scrolling we have 60+. Also have dvb as well in menu plus lots of other stuff Quote
jmerch Posted January 26, 2012 Author Posted January 26, 2012 I like the pull down menu idea, but we don't use them...all ribbon and quick commands here. I was hoping in a DCL list you could still type the beginning letter of the file and it would skip to there... Quote
jmerch Posted January 26, 2012 Author Posted January 26, 2012 Thanks for all the help/suggestions. Here's my "go-at-it" and am getting the fixnump error. After the error, the command line still spits out each file I'm requesting out of the directory though...just not in a dialog box I have read a DCL tutorial, understand most of it but some of the examples went in a different direction so I had to start trial and error (I know, don't shoot me). Any assistance with this is much appreciated. (defun c:test2() (setq scriptlist (vl-directory-files "Z:/CAD/CAD-MECH/PM Shared/Scripts" "*.cod" 1)) (if(not(new_dialog "scripts" scriptlist))(exit)) (start_list "scr_list") (mapcar 'add_list scriptlist) (end_list) (action_tile "accept" "(setq mytile (atoi(get_tile \"scr_list\")))(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") (if (= (getvar "DIASTAT") 1) (executescript (stracat "Z:/CAD/CAD-MECH/PM Shared/Scripts" (nth mytile scriptlist))) ) ) Quote
MSasu Posted January 26, 2012 Posted January 26, 2012 I have made some corrections to your code - see below. Most important comment is to avoid to use the same variable to store the list of files and the ID of dialog box: (defun c:test2() (setq scriptlist (vl-directory-files "Z:/CAD/CAD-MECH/PM Shared/Scripts" "*.cod" 1)) [color=red](setq DCLid (load_dialog "scr_list.dcl"))[/color] (if (not (new_dialog "scripts" [color=red]DCLid[/color])) (exit)) (start_list "scr_list") (mapcar 'add_list scriptlist) (end_list) (action_tile "accept" "(setq mytile (atoi (get_tile \"scr_list\")))(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") [color=red] (start_dialog)[/color] [color=red] (unload_dialog DCLid)[/color] (if (= (getvar "DIASTAT") 1) (executescript ([color=red]strcat[/color] "Z:/CAD/CAD-MECH/PM Shared/Scripts" (nth mytile scriptlist))) ) ) Regards, Mircea Quote
jmerch Posted January 26, 2012 Author Posted January 26, 2012 I'm so....not smart. I should have known to load the fricking dialog...duh Thanks for your corrections. I got the DCL box to pop up now. The only outstanding issue is when the user selects the file and clicks ok, the "executescript" function still runs like normal and has the user re-select it...which is not what I'm shooting for. So, from what I see, it's not gathering the whole path of "Z:/CAD/CAD-MECH/PM Shared/Scripts/Script Name". I think it has something to do with mytile returning an integer...but I tried putting itoa in the (nth mytile scriptlist). Quote
MSasu Posted January 26, 2012 Posted January 26, 2012 I just spotted another issue: (strcat "Z:/CAD/CAD-MECH/PM Shared/Scripts[color=red]/[/color]" (nth mytile scriptlist)) Regards, Mircea Quote
jmerch Posted January 26, 2012 Author Posted January 26, 2012 That's what did it....thanks Mircea! Quote
MSasu Posted January 26, 2012 Posted January 26, 2012 Glad to help you. You're welcome! Regards, Mircea Quote
jmerch Posted January 26, 2012 Author Posted January 26, 2012 I'd also like to tweak this so that the .cod doesn't show up in the list....from what I've researched, it appears the best method would be to use vl-filename-base. But where can I introduce this? Quote
BlackBox Posted January 26, 2012 Posted January 26, 2012 I'd also like to tweak this so that the .cod doesn't show up in the list....from what I've researched, it appears the best method would be to use vl-filename-base. But where can I introduce this? Lemon squeezy. (setq scriptlist [color=blue](mapcar 'vl-filename-base[/color] (vl-directory-files "Z:/CAD/CAD-MECH/PM Shared/Scripts" "*.cod" 1)[color=blue])[/color]) Quote
MSasu Posted January 26, 2012 Posted January 26, 2012 I will do instead: (mapcar 'add_list (mapcar 'vl-filename-base scriptlist)) Regards, Mircea Quote
BlackBox Posted January 26, 2012 Posted January 26, 2012 Out of curiosity, would this work? (mapcar '(lambda (x) (add_list (vl-filename-base x))) (vl-directory-files "Z:/CAD/CAD-MECH/PM Shared/Scripts" "*.cod" 1)) ... If so, this only requires the list to be iterated once, rather than twice (once for each mapcar). Quote
Recommended Posts
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.