tnvsb Posted April 4, 2016 Share Posted April 4, 2016 Dear Friends, I am trying to develop a code, that should take the user input and then it should match to assigned list values, after it should give the output as an alert box. Following is the code, I wrote. But not working. Please help me .. (DEFUN C:LSTBRKER () (setq BRKLST (LIST (LIST "SM" 6 16 32 64 100) (LIST "MED" 125 160 200 250 315 400) (LIST "HVY" 600 800 950 1000 1500 2000 3000) (LIST "HY+" 3500 4500 5700 6200 8500)) ) (setq RQBLST (getstring "\n Please Enter the Required Breaker Catogories = ")) (SETQ REQCAP (STRCASE RQBLST)) (if (= (REQCAP) (assoc BRKLST LIST)) (Progn (Princ (assoc BRKLST)) ) ) ) advanced thanks Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 4, 2016 Share Posted April 4, 2016 Welcome to CADTutor. Is this what you are after? (defun c:test (/ lst st f) (setq lst '(("SM" 6 16 32 64 100) ("MED" 125 160 200 250 315 400) ("HVY" 600 800 950 1000 1500 2000 3000) ("HY+" 3500 4500 5700 6200 8500)) ) (if (and (/= "" (setq st (getstring "\n Please Enter the Required Breaker Catogories = "))) (setq f (assoc (strcase st) lst)) ) (alert (vl-princ-to-string f)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 4, 2016 Share Posted April 4, 2016 I prefer ( getkword ) in these types of scenarios: [b][color=BLACK]([/color][/b]defun c:lstbrker [b][color=FUCHSIA]([/color][/b]/ brklst input data[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq brklst '[b][color=NAVY]([/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"SM"[/color] 6 16 32 64 100[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"MED"[/color] 125 160 200 250 315 400[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"HVY"[/color] 600 800 950 1000 1500 2000 3000[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"HY+"[/color] 3500 4500 5700 6200 8500[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1 [color=#2f4f4f]"Sm Med hVy Hy+"[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq input [b][color=NAVY]([/color][/b]strcase [b][color=MAROON]([/color][/b]getkword [color=#2f4f4f]"\n Please Enter the Required Breaker Catogories - Sm/Med/hVy/Hy+ "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq data [b][color=NAVY]([/color][/b]assoc input brklst[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]terpri[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1 data[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 5, 2016 Share Posted April 5, 2016 My prefrence now days is to use a list box function see lee-mac.com forces a correct pick only. (LM:listbox "Please pick" '("SM" "MED" HVY" "HY+") 1) Quote Link to comment Share on other sites More sharing options...
tnvsb Posted April 5, 2016 Author Share Posted April 5, 2016 Hi Thank you Very Much for your quick support and accurate reply...... Quote Link to comment Share on other sites More sharing options...
tnvsb Posted April 5, 2016 Author Share Posted April 5, 2016 Thank you very much Tharwat for quick reply.. and nice solution... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 5, 2016 Share Posted April 5, 2016 Thank you very much Tharwat for quick reply.. and nice solution... You are most welcome. Quote Link to comment Share on other sites More sharing options...
tnvsb Posted April 5, 2016 Author Share Posted April 5, 2016 Hi David Bethel, Thank you very much for your valuable input, that's looking nice. Your option making the lisp code output great. it's also showing the required input... Great thing....Thanks once more.. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 5, 2016 Share Posted April 5, 2016 My prefrence now days is to use a list box function see lee-mac.com forces a correct pick only. LOL I guess that I'm more of a keyboarder rather than a mouser Quote Link to comment Share on other sites More sharing options...
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.