Jump to content

Need Urgent Help For Lookup


tnvsb

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 8)

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