Author Topic: converting characters to Title Case  (Read 5984 times)

0 Members and 1 Guest are viewing this topic.

Peter Jamtgaard

  • Guest
Re: converting characters to Title Case
« Reply #15 on: February 25, 2006, 05:33:14 PM »
Maybe

Code: [Select]
(defun TitleCase (strSentence / intCount intItem lstCharacters lstCharacters2)
 (setq strSentence (strcase strSentence 'T)
       intCount 0)
 (repeat (length (setq lstCharacters (vl-string->list strSentence)))
  (setq intItem (nth intCount lstCharacters))
  (if (and (or (= intCount 0)
               (= (nth (1- intCount) lstCharacters) 32)
           )
           (> intItem 96)
           (< intItem 123)
      )
   (setq intItem (- intItem 32))     
  )
  (setq lstCharacters2 (cons intItem lstCharacters2)
        intCount       (1+ intCount)
  )
 )
 (print (reverse lstCharacters2))
 (vl-list->string (reverse lstCharacters2))
)