Jump to content

Recommended Posts

Posted

I have a task which I'm going to try and use LISP for. I'm reasonably sure I could do this in VBA with the INSTR command but since some other tasks are done with LISP I'm going to try to stay with that language for now.

 

We have some drawings which are staged in a certain location so that they can be reviewed by one of the designers. The typical filename pattern is comprised of 5 digits like this:

 

99999.dwg
There are some drawings which once checked and found to contain error(s) will be named like this:

 

99999 (Pending).dwg
When the time comes, I'd like to rename the file and remove the (Pending) suffix. But as you can see, sometimes this pattern will be there, other times it will not. Is there something similar in LISP to the INSTR command with VB which would identify this pattern and then let me re-concatenate the string without the (Pending) text?
Posted (edited)

I think I found what I'm looking for with wcmatch....will test this method.... and vl-string-search...one of these should work.

 

UPDATE: Thanks RenderMan..your suggestion for vl-string-search worked quite well.

 

(vl-load-com)

(defun c:approve (/ fname x)
 (setq x (vl-string-search "(Pending)" (getvar "dwgname")))

 (if (> x 0)
   (setq fname (strcat (substr (getvar "dwgname") 1 x) ".dwg"))
   (setq fname (getvar "dwgname"))
 )

 (princ); exit quietly
); end function

Edited by Bill Tillman

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