TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Marc'Antonio Alessi on April 11, 2019, 03:43:21 AM

Title: Wcmatch: another silly question
Post by: Marc'Antonio Alessi on April 11, 2019, 03:43:21 AM
I use very often this simple but very useful function:
Code: [Select]
(defun _WcmatchAll (text patterns) ; M. Puckett
  (vl-every
    (function (lambda (p) (wcmatch (strcase text) (strcase p))))
    patterns
  )
)
Purpose: discard anonymous blocks *X*, *U*, *D* and names starting with "X_"
Code: [Select]
(_WcmatchAll "*U254"   '("[~*]*" "~X_*")) => nil
(_WcmatchAll "*D45t"   '("[~*]*" "~X_*")) => nil
(_WcmatchAll "*X4gh"   '("[~*]*" "~X_*")) => nil
(_WcmatchAll "X_123"   '("[~*]*" "~X_*")) => nil
New Purpose: discard anonymous blocks *X*, *D* and names starting with "X_" but NOT *U* anonymous blocks
Code: [Select]
(_WcmatchAll "*U254"   '("[~*]D*"    "[~*]X*"    "~X_*")) => nil ?
(_WcmatchAll "*U254"   '("[~*]~D*"   "[~*]~X*"   "~X_*")) => nil ?
(_WcmatchAll "*U254"   '("[~*][~D]*" "[~*][~X]*" "~X_*")) => nil ?
???
Title: Re: Wcmatch: another silly question
Post by: kpblc on April 11, 2019, 03:53:46 AM
Code - Auto/Visual Lisp: [Select]
  1. (_wcmatchall "*U254" '("~`*~D*" "~`*~X*" "~X_*"))
??
Title: Re: Wcmatch: another silly question
Post by: Marc'Antonio Alessi on April 11, 2019, 04:54:15 AM
Code - Auto/Visual Lisp: [Select]
  1. (_wcmatchall "*U254" '("~`*~D*" "~`*~X*" "~X_*"))
??
Code: [Select]
(_wcmatchall "*U254" '("~`*~D*" "~`*~X*" "~X_*")) => T   OK
(_wcmatchall "X_123" '("~`*~D*" "~`*~X*" "~X_*")) => nil OK
(_wcmatchall "*D45t" '("~`*~D*" "~`*~X*" "~X_*")) => T   must be nil
(_wcmatchall "*X4gh" '("~`*~D*" "~`*~X*" "~X_*")) => T   must be nil
Title: Re: Wcmatch: another silly question
Post by: ronjonp on April 11, 2019, 09:40:58 AM
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (_wcmatchall "*U254" '("~`*[DX]*" "~X_*"))
  2. (_wcmatchall "X_123" '("~`*[DX]*" "~X_*"))
  3. (_wcmatchall "*D45t" '("~`*[DX]*" "~X_*"))
  4. (_wcmatchall "*X4gh" '("~`*[DX]*" "~X_*"))
Title: Re: Wcmatch: another silly question
Post by: Marc'Antonio Alessi on April 11, 2019, 10:19:13 AM
Thanks!  :-) It wasn't that simple, grazie mille.  :yes:
Code: [Select]
New Purpose: discard anonymous blocks *X*, *D* and names starting with "X_" but NOT *U* anonymous blocks
                    (all other names are ok)
(_wcmatchall "Abcde" '("~`*[DX]*" "~X_*")) => T   OK
(_wcmatchall "*U254" '("~`*[DX]*" "~X_*")) => T   OK
(_wcmatchall "X_123" '("~`*[DX]*" "~X_*")) => nil OK
(_wcmatchall "*D45t" '("~`*[DX]*" "~X_*")) => nil OK
(_wcmatchall "*X4gh" '("~`*[DX]*" "~X_*")) => nil OK
Title: Re: Wcmatch: another silly question
Post by: ronjonp on April 11, 2019, 10:23:11 AM
Thanks!  :-) It wasn't that simple, grazie mille.  :yes:
Code: [Select]
New Purpose: discard anonymous blocks *X*, *D* and names starting with "X_" but NOT *U* anonymous blocks
                    (all other names are ok)
(_wcmatchall "Abcde" '("~`*[DX]*" "~X_*")) => T   OK
(_wcmatchall "*U254" '("~`*[DX]*" "~X_*")) => T   OK
(_wcmatchall "X_123" '("~`*[DX]*" "~X_*")) => nil OK
(_wcmatchall "*D45t" '("~`*[DX]*" "~X_*")) => nil OK
(_wcmatchall "*X4gh" '("~`*[DX]*" "~X_*")) => nil OK
Glad to help :) .. this should work too if you want to use something a bit more legible.
Code - Auto/Visual Lisp: [Select]
  1. (_wcmatchall "Abcde" '("~`*D*" "~`*X*" "~X_*"))
  2. (_wcmatchall "*U254" '("~`*D*" "~`*X*" "~X_*"))
  3. (_wcmatchall "X_123" '("~`*D*" "~`*X*" "~X_*"))
  4. (_wcmatchall "*D45t" '("~`*D*" "~`*X*" "~X_*"))
  5. (_wcmatchall "*X4gh" '("~`*D*" "~`*X*" "~X_*"))
Title: Re: Wcmatch: another silly question
Post by: Marc'Antonio Alessi on April 11, 2019, 10:29:14 AM
perfect  :smitten:
Title: Re: Wcmatch: another silly question
Post by: Lee Mac on April 11, 2019, 01:15:45 PM
Alternatively:
Code - Auto/Visual Lisp: [Select]
  1. (not (wcmatch <blockname> "`*[DX]*,X_*"))

No custom function required.
Title: Re: Wcmatch: another silly question
Post by: Marc'Antonio Alessi on April 11, 2019, 02:39:26 PM
Alternatively:
Code - Auto/Visual Lisp: [Select]
  1. (not (wcmatch <blockname> "`*[DX]*,X_*"))

No custom function required.
Grazie  :-)