TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Dommy2Hotty on October 28, 2004, 12:47:00 PM

Title: (?) Replace \\ with \ from dwgprefix
Post by: Dommy2Hotty 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)
  )
Title: (?) Replace \\ with \ from dwgprefix
Post by: MP 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. :)
Title: (?) Replace \\ with \ from dwgprefix
Post by: Dommy2Hotty 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!
Title: (?) Replace \\ with \ from dwgprefix
Post by: MP 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. :)
Title: (?) Replace \\ with \ from dwgprefix
Post by: Keith™ on October 28, 2004, 01:15:46 PM
Ditto MP
Title: (?) Replace \\ with \ from dwgprefix
Post by: hendie 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"))