filtering variable text
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
filtering variable text

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
mnash
Guest





Posted: Tue Jan 11, 2005 8:16 pm    Post subject: filtering variable text Reply with quote

In one drawing a certain variable is so many characters long say 7, and in another drawing the same type of variable is 9 characters long. How do I make the variable in both cases to get from 1234567 to 123 in the first drawing and 12345 in the second drawing. Eseentially the last four characters in the variable are useless for me. The variable I'm referring to is the filename and I want to get rid of the ".dwg" at the end.
thanks

Back to top
Jason Piercey
Guest





Posted: Tue Jan 11, 2005 8:29 pm    Post subject: Re: filtering variable text Reply with quote

(vl-filename-base "abc.dwg")
"abc"

(vl-filename-base "abc.dwaasdasdg")
"abc"

--
Autodesk Discussion Group Facilitator



"mnash" <nospam@address.withheld> wrote in message
news:4257564.1105456649278.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
In one drawing a certain variable is so many characters long say 7, and in
another drawing the same type of variable is 9 characters long. How do I

make the variable in both cases to get from 1234567 to 123 in the first
drawing and 12345 in the second drawing. Eseentially the last four
characters in the variable are useless for me. The variable I'm referring
to is the filename and I want to get rid of the ".dwg" at the end.
> thanks
Back to top
Kent Cooper, AIA
Guest





Posted: Tue Jan 11, 2005 9:51 pm    Post subject: Re: filtering variable text Reply with quote

Or,

(setq howlong (strlen (getvar "dwgname")))
(setq dwgnameonly (substr (getvar "dwgname") 1 (- howlong 4)))

"dwgnameonly" will be what you're looking for. The same approach will give
you back any text string with four characters removed from the end, in case
you need such a thing for anything other than the drawing name (which is the
only situation Jason's will work in).
--
Kent Cooper, AIA


"mnash" wrote...
Quote:
In one drawing a certain variable is so many characters long say 7, and in
another drawing the same type of variable is 9 characters long. How do I
make the variable in both cases to get from 1234567 to 123 in the first
drawing and 12345 in the second drawing. Eseentially the last four
characters in the variable are useless for me. The variable I'm referring
to is the filename and I want to get rid of the ".dwg" at the end.
thanks


Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB