Author Topic: Capital letter  (Read 1805 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 462
Capital letter
« on: September 15, 2014, 07:27:32 PM »
I know that "strcase" converts text to uppercase or lowercase.
Is there any function to convert the 1st letter of a text to uppercase and the rest to lowercase?
Thanks in advance.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Capital letter
« Reply #1 on: September 15, 2014, 07:30:28 PM »

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Capital letter
« Reply #2 on: September 17, 2014, 08:39:25 PM »
Thanks Lee. Your tips are very helpful. Cheers!

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Capital letter
« Reply #3 on: September 18, 2014, 06:31:11 PM »
You're welcome!  :-)

tedg

  • Swamp Rat
  • Posts: 811
Re: Capital letter
« Reply #4 on: September 19, 2014, 02:21:31 PM »
Thanks Lee. Your tips are very helpful. Cheers!
Tips?
More like well explained, downloadable working examples!!


Lee is a freakin' Genius, we're not worthy.


Don't forget to donate, and tip your bartenders and waitresses too.


 ^-^

Windows 10 Pro 64bit, AutoCAD 2023, REVIT 2023

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
Re: Capital letter
« Reply #5 on: September 19, 2014, 02:36:47 PM »
Found this one and a ton more with a quick search of the forum (I'll post the one I supposedly done and let the other people post theirs).

Code - Auto/Visual Lisp: [Select]
  1. (defun J7:TitleCase ( s / )
  2.   (setq s (strcase s T))
  3.   (while (setq sp (vl-string-position 32 s sp))
  4.          (setq s (vl-string-subst
  5.                    (chr (boole 2 (vl-string-elt s (1+ sp)) 32))
  6.                    (chr (vl-string-elt s (1+ sp)))
  7.                    s
  8.                    (1+ sp)
  9.                    )
  10.                sp       (1+ sp)
  11.                )
  12.          )
  13.   (vl-string-subst
  14.     (chr (boole 2 (vl-string-elt s 0) 32))
  15.     (chr (vl-string-elt s 0))
  16.     s
  17.     )
  18.   )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org