Author Topic: How to make AND work?  (Read 1342 times)

0 Members and 1 Guest are viewing this topic.

jmcshane

  • Newt
  • Posts: 83
How to make AND work?
« on: March 16, 2010, 07:15:27 AM »
In a (vlax-for ) expression I am trying to grab an MText object which has a specific word in it.

Can anyone enlighten me as to why this doesn't work?
Code: [Select]
     (if (and (= (vla-get-ObjectName obj) "AcDbMText")
                 (wcmatch (strcase (vla-get-TextString obj)) "COPYRIGHT"))
          (progn......)

Thanks in Advance

John
John.

Civil 3D 2021. Windows 10

Joe Burke

  • Guest
Re: How to make AND work?
« Reply #1 on: March 16, 2010, 08:07:47 AM »
John,

Consider...

Command: (setq str "THIS COPYRIGHT NOTICE")
"THIS COPYRIGHT NOTICE"

Command: (wcmatch str "*COPYRIGHT*")
T

Command: (wcmatch str "COPYRIGHT")
nil

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to make AND work?
« Reply #2 on: March 16, 2010, 08:17:36 AM »
It is also case sensitive.

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to make AND work?
« Reply #3 on: March 16, 2010, 08:24:10 AM »
An alternate method to consider.

(vl-string-search pattern string [start-pos])
Searches for the specified pattern in a string


(setq str "THIS copyright notice")

(vl-string-search "COPYRIGHT" (strcase str))

or

(wcmatch (strcase str) "*COPYRIGHT*")
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

jmcshane

  • Newt
  • Posts: 83
Re: How to make AND work?
« Reply #4 on: March 16, 2010, 08:28:06 AM »
Quote
Consider...

Command: (setq str "THIS COPYRIGHT NOTICE")
"THIS COPYRIGHT NOTICE"

Command: (wcmatch str "*COPYRIGHT*")
T

Command: (wcmatch str "COPYRIGHT")
nil

Ouch Joe.  That was so obvious, it hurts. :oops:

Quote
It is also case sensitive.
Thanks CAB, I was using the STRCASE against it.


John.

Civil 3D 2021. Windows 10

Joe Burke

  • Guest
Re: How to make AND work?
« Reply #5 on: March 16, 2010, 08:43:49 AM »
John,

It's all good  :-)