Jump to content

Recommended Posts

Posted (edited)

Hey guys and gals long time no see. Actually last time I posted here this script in its child form.

As I said before I have never liked the Functionality of the getkword function so I made my own. I was using it lately and it wasn't working the way I wanted it to fully. So, I forced it to grow up a bit.

 

Please leave me comments on ways you think I can make this better or any issues you find. I used it for a bit and fixed any errors I could find.

 

I know of 1 error, kind of, when using the Example below New Mexico will conflict with the Exit to Main function but it is kind of doing what it is suppose to do. EXI will find both "New Mexico" and "Exit to Main" unless used before refined search which will return "New Mexico". I guess I can make it so if only 2 results return and 1 is "Exit to Main" the other is used as the "Answer" or "Keyword".

 

 

Example

(U-keyword 7 (list "ALabama" "AlasKa" "AriZona" "ARkansas"
"CAlifornia" "COlorado" "CoNnecticut" "Delaware" "Florida" "Georgia"
"Hawaii" "IDaho" "ILlinois" "INdiana" "IOwa" "KAnsas" "KEntucky"
"LOuisiana" "MAine" "MaRyland" "MaSsachusetts" "MIchigan"
"MiNnesota" "MississiPpi" "MissoUri" "MOntana" "NeBraska" "NeVada"
"New Hampshire" "New Jersey" "New Mexico" "New York"
"North Carolina" "North Dakota" "OHio" "OKlahoma" "ORegon" 
"Pennsylvania" "Rhode Island" "South Carolina" "South Dakota"
"TeNnessee" "TeXas" "Utah" "VErmont" "Virgin Islands" "ViRginia" 
"WAshington" "West Virginia" "WIsconsin" "WYoming") "\nState:")

Use:

(U-keyword "Input type (integer)" (list "Answers") "Question")

Description

- Multiple and Super Seeding search results.
 Super Seed Hiarchy
  Cap Match > Perfect match > WC Spot Match
   Example using Super Seed and Search of AL
    Cap Match
     ALabama   -   Matched
    Perfect Match
     Alabama
     Alaska
     California
    WC Spot Match
     Alabama
     Alaska
     California
     Maryland
     North Carolina
     South Carolina
   Example using Super Seed and Search of CALI
    Cap Match
     -
    Perfect Match
     California   -   Matched
    WC Spot Match
     California
     North Carolina
     South Carolina
   Example using Super Seed and Search of ALS
    Cap Match
     -
    Perfect Match
     -
    WC Spot Match
     Alaska   -   Matched
- Cap match based on caps used in List
- Will designate if Search didn't find anything
- Allows for search of multiple word that wasnt allowed in regular Keyword search
- If multiples are found will return all sutiable results for a refined search.
- Add option to return to Original Search Result

 

Vlisp Code

 

(defun U-Keyword (inittype lst Question /)
 (if (/= Question "\nResults are inconclusive please refine")
   (progn
     (setq orginittype inittype)
     (setq orglst lst)
     (setq orgquestion Question)
     )
   )
 (setq foundmatch nil)
 (setq foundmlist nil)
 (setq searchtype inittype)
 (setq opt "")
 (foreach item lst
   (if (= opt "")
     (setq opt item)
     (setq opt (strcat opt "/" item))
     )
   )
 (setq kwext nil)
 (while (= kwext nil)
   (if (/= question "")
     (progn
(initget inittype)
(setq selection (getstring (strcat "\n" Question " [" opt "]:")))
)
     (progn
(initget inittype)
(setq selection (getstring (strcat "\nPlease input option [" opt "]:")))
)
     )
   (setq STRCASEmatches 0)
   (setq strcon (strlen selection))
   (setq count 1)
   (setq wmat nil)
   (while (< count (+ strcon 1))
     (setq letter (substr (strcase selection) count 1))
     (if (= wmat nil)
(setq wmat (strcat "*" letter "*"))
(setq wmat (strcat wmat letter "*"))
)
     (setq count (+ count 1))
     )
   (foreach item lst
     (if (wcmatch item (strcat wmat))
(progn
  (setq foundmatch item)
  (setq STRCASEmatches (+ STRCASEmatches 1))
  )
)
     )
   (if (= STRCASEmatches 1)
     (setq kwext 1)
     (progn
(setq strcon (strlen selection))
(setq count 1)
(setq wmat nil)
(while (< count (+ strcon 1))
  (setq letter (substr selection count 1))
  (if (= wmat nil)
    (setq wmat (strcat "*" letter "*"))
    (setq wmat (strcat wmat letter "*"))
    )
  (setq count (+ count 1))
  )
(setq matches 0)
(setq perfect nil)
(setq perfectm 0)
(foreach item lst
  (if (wcmatch (strcase item) (strcase wmat))
    (if (wcmatch (Strcase item) (strcase (Strcat "*" selection "*")))
      (progn
 (setq perfect item)
 (setq perfectm (+ perfectm 1))
 (setq matches (+ matches 1))
 (setq foundmatch item)
 (setq foundmlist (append foundmlist (list item)))
 )
      (progn
 (setq matches (+ matches 1))
 (setq foundmatch item)
 (setq foundmlist (append foundmlist (list item)))
 )
      )
    )
  )
(setq add 1)
(foreach found foundmlist
  (if (= found "Exit to Main")
    (setq add 0)
    )
  )
(if (= add 1)
  (setq foundmlist (append foundmlist (list "Exit to Main")))
  )
(if (and (/= perfect nil) (= perfectm 1) (/= foundmatch "Exit to Main"))
  (progn
    (setq kwext 1)
    (setq foundmatch perfect)
    )
  (progn
    (cond
      ((= matches 0)(princ "\nNo matches found. Please try again."))
      ((= matches 1)(setq kwext 1))
      ((> matches 1)(U-keyword searchtype foundmlist "\nResults are inconclusive please refine"))
      (t (princ "\nHow the hell did you get here?"))
      )
    )
  )
)
     )
   )
 (if (= foundmatch "Exit to Main")
   (U-keyword orginittype orglst orgquestion)
   foundmatch
   )
 )

Edited by CADWarrior
Horrible grammar forgot to proofread

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