Author Topic: vl-string-right-trim question  (Read 2129 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
vl-string-right-trim question
« on: May 18, 2006, 08:58:58 AM »
Code: [Select]
;;filename
  (setq @fname1 (getvar "dwgname")
@fname2 (vl-string-right-trim ".dwg" @fname1)
@fname2 (vl-string-right-trim ".DWG" @fname1)
@fname3 (getvar "dwgprefix")
@fname (strcat @fname3 @fname2))

I have this piece of code, but how can I get it to search for ".dwg" irrespective of case?
One persons machine always puts the suffix in uppercase while all the rest are lower case.

I want to remove either option to make a plot file name based on just the file name minus the suffix.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

ronjonp

  • Needs a day job
  • Posts: 7533
Re: vl-string-right-trim question
« Reply #1 on: May 18, 2006, 09:24:23 AM »
Possibly:

(vl-string-right-trim (strcase ".dwg") (strcase @fname1))

All lowercase:

Code: [Select]
(strcat (strcase (getvar 'dwgprefix)T)
(vl-string-right-trim
  (strcase ".dwg" T)
  (strcase (getvar 'dwgname)T)
)
)

All uppercase:

Code: [Select]
(strcat (strcase (getvar 'dwgprefix))
(vl-string-right-trim
  (strcase ".dwg")
  (strcase (getvar 'dwgname))
)
)

« Last Edit: May 18, 2006, 09:35:48 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: vl-string-right-trim question
« Reply #2 on: May 18, 2006, 09:38:39 AM »
also look at
vl-filename-base
vl-filename-directory
vl-filename-extension

Code: [Select]
;;;  Returns trimmed string if string is long enough
;;;          ""  if string is to short
(defun string-right-trim (string num)
    (if (> (strlen string) num)
      (substr string 1 (- (strlen string) num))
      ""
    )
)

(defun string-left-trim (string num)
    (if (> (strlen string) num)
      (substr string (1+ num))
      ""
    )
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Didge

  • Bull Frog
  • Posts: 211
Re: vl-string-right-trim question
« Reply #3 on: May 18, 2006, 09:47:17 AM »
Is this what you're looking for?

(setq @fname (vl-filename-BASE (getvar "dwgname")))

Think Slow......