Author Topic: (?) Replace \\ with \ from dwgprefix  (Read 2791 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
(?) Replace \\ with \ from dwgprefix
« on: October 28, 2004, 12:47:00 PM »
Here's my code...what would I need to add/change to REPLACE the \\ with \ from the returned path?
Code: [Select]
(defun c:DWGNAME (/ path name)
  (setq path (getvar "dwgprefix"))
  (setq name (getvar "dwgname"))
  (setq name (strcat path name))
  (setq name (substr name 1 (- (strlen name) 4)))
  (print name)
  (princ)
  )

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
(?) Replace \\ with \ from dwgprefix
« Reply #1 on: October 28, 2004, 12:55:21 PM »
I can't think of why you would want to do such a thing but vl-string-subst will allow you to substitute one string for another, e.g. "" for "\\". Also, you might want to consider using vl-filename-base to strip extensions.

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

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
(?) Replace \\ with \ from dwgprefix
« Reply #2 on: October 28, 2004, 12:59:34 PM »
Quote from: MP
I can't think of why you would want to do such a thing but vl-string-subst will allow you to substitute one string for another, e.g. "" for "\\". Also, you might want to consider using vl-filename-base to strip extensions.

Cheers. :)


OOPS :oops: Edited the title and my first post...not take out, replace \\ with \

My bad!

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
(?) Replace \\ with \ from dwgprefix
« Reply #3 on: October 28, 2004, 01:08:08 PM »
Quote from: Dommy2Hotty
Edited the title and my first post...not take out, replace \\ with \ ...

Ummm, you don't really want to do this (you can't anyway). Please read the "Control Characters in Strings" section in the Visual LISP Developer's Guide. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(?) Replace \\ with \ from dwgprefix
« Reply #4 on: October 28, 2004, 01:15:46 PM »
Ditto MP
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hendie

  • Guest
(?) Replace \\ with \ from dwgprefix
« Reply #5 on: October 29, 2004, 05:13:43 AM »
I'm not sure what you are trying to achieve, but have you tried
Code: [Select]
(fnsplitl (getvar "dwgname"))