Author Topic: would you help me with wcmatch  (Read 5489 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: would you help me with wcmatch
« Reply #15 on: August 21, 2006, 10:05:13 PM »
Just trying to communicate a little better.... that's all

T o o   m u c h   i r o n y ,   h e a d   e x p l o d i n g   . . .
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: would you help me with wcmatch
« Reply #16 on: August 21, 2006, 10:41:39 PM »
For those that don't get the irony bit ...

( FromBase64 "G5x_Rm0WQb_jQaJVPqtjSm0rP54o75W_8rBVRq4tPLsbEk" )

=> "Does anyone know what he's sayin'?"

< insert maniacal laughter here >
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

LE

  • Guest
Re: would you help me with wcmatch
« Reply #17 on: August 21, 2006, 10:51:56 PM »
I thought that Irony means when someone iron their clothes.....  :lol:

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: would you help me with wcmatch
« Reply #18 on: August 22, 2006, 01:50:19 AM »
This one seems to work on every LE's tests, and some others :
"20.5.0,20.5,20.5" -> nil
"3xx" -> nil

Code: [Select]
(cond
  ((and
     (setq n (vl-string-position 88 (strcase rValue2)))
     (= (+ n 1) (strlen rValue2))
     (numberp (read (substr rValue2 1 n)))
   )
  )
  (T
   (while (setq n (vl-string-position 44 rValue2))
     (setq lst    (cons (substr rValue2 1 n) lst)
   rValue2 (substr rValue2 (+ 2 n))
     )
   )
   (setq lst (cons rValue2 lst))
   (vl-every '(lambda (x)
(and (= (strlen x) (strlen (vl-princ-to-string (read x))))
     (numberp (read x))
)
      )
     lst
   )
  )
)
« Last Edit: August 22, 2006, 02:09:03 AM by gile »
Speaking English as a French Frog

Tramber

  • Guest
Re: would you help me with wcmatch
« Reply #19 on: August 22, 2006, 04:32:11 AM »
Hi everybody and thanks to everyone  :kewl:

The MP code seems to be very efficient :

Code: [Select]
    (defun _CSV2List ( csv / flag value result );;  quick/simple implementation, don't beat me up   ; Don't worry !
      (foreach code (reverse (vl-string->list csv))
(if (eq 44 code)
  (setq result (cons value result) value nil)
  (setq value (cons code value))
  )
)
      (mapcar '(lambda (x) (if x (vl-list->string x) ""))(cons value result)))
   
    (defun tst ( text ) (or(wcmatch text "*[Xx]")(vl-every '(lambda (x) (distof x 2)) (_CSV2List text))))

BUT there is still a problem remaining :
(tst "x3x") returns T instead of nil.
I tried to modify the wcmatch that is involved in that case in the tst function, but I didn't succeed. I'm still lost and tried (wcmatch "x3x" "[~0-9`,]*") with no success. Help !

NB : I understood and will use _CSV2List and it's great.
I understood most of your routines, guys, and they all are brilliant. But I'm back to my first problem : how to filter INTEGER+letter X ?
« Last Edit: August 22, 2006, 04:36:49 AM by Call me Bert' »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: would you help me with wcmatch
« Reply #20 on: August 22, 2006, 07:04:38 AM »
Hi Bert. Thank you for the kind words but --

(1) You should write a better version of CSV2LIST as it wasn't intended to be an industrial strength function, just a quick one off to illuminate one possible technique, not necessarilly the implementation, to a solution.

(2) You're killin' me. Why are you changing "#[Xx]" to "*[Xx]"?? That's not how I posted it but that's how you are using it and quoting it back.

The originally posted filter "#[Xx]" will allow a number and upper|lowercase version of "x", e.g.  "0x" thru "9x", and that's it --

    (wcmatch "1X" "#[Xx]") => T
    (wcmatch "2X" "#[Xx]") => T
    (wcmatch "3X" "#[Xx]") => T
    (wcmatch "9X" "#[Xx]") => T
    (wcmatch "9X9" "#[Xx]") => nil


If "0x" would be considered invalid you could use --

    (wcmatch text "[1-9][Xx]")

The filter you posted "*[Xx]" will allow anything (or nothing) prefixing upper|lowercase "x", everything from a simple "x" to "AllYourLispAreBelongToX" would pass such a filter.

    (wcmatch "X" "*[Xx]") => T
    (wcmatch "AllYourLispAreBelongToX" "*[Xx]") => T


Does this help? Am I completely missing your point? Do I need a coffee? Ok, I know the anwwer at least one of these: Medic!

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: would you help me with wcmatch
« Reply #21 on: August 22, 2006, 07:25:01 AM »
Whlie I have your attention, is it possible you are trying to prompt in a way that is not ideal. I don't pretend to understand what you're trying to build here but from the little I can glean from all this would lean me towards branched prompting: Ask the user if the want absolute or scaled input, if the former allow a list of numbers, otherwise a single scale factor, but hey, I'm still not awake.

Abort|Ignore|Retry|Fail. :doa:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Tramber

  • Guest
Re: would you help me with wcmatch
« Reply #22 on: August 22, 2006, 08:05:35 AM »
Well, the trouble is that I noticed * allowed me to input a "21x" (more than 10), not the #.

But, I've been back to school, reading the HLP (that doesn't explain very clearly wcmatch, overwise I wouldn't ask you all). No matter where we live we all have to read the documentation in English, and that the reason why I was lost, the story of the brackets and the ~ was not clear to me.

Then I got a brilliant idea based on your lesson and finally understood the consequences of my crime :

Code: [Select]
(defun tst ( text ) (or(wcmatch text "##[Xx]")(wcmatch text "#[Xx]")(vl-every '(lambda (x) (distof x 2)) (_CSV2List text))))
And all my trouble seem to be so far away....
...better than yesterday  ^-^

Thank you and sorry for that very messy conversation.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: would you help me with wcmatch
« Reply #23 on: August 22, 2006, 08:18:30 AM »
Sorry if I sounded grumpy Bert, just woke up prior to my fisrt post this am.

Just a quick note, you can separate wcmatch patterns with a comma --

(wcmatch text "#[Xx],##[Xx]")

or

(wcmatch text "[1-9][Xx],[1-9][0-9][Xx]")

etc.

Well off to work ...

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst