Author Topic: cHANGE cASE lISP  (Read 3716 times)

0 Members and 1 Guest are viewing this topic.

M-dub

  • Guest
cHANGE cASE lISP
« on: November 12, 2003, 01:34:10 PM »
Just thought I'd share this one...Got it from Cadalyst.  Don't use it very often, but when I do, I'm VERY thankful that I have it.

Enjoy

Code: [Select]
;Tip1359.LSP:  CASE.LSP   Change Case   (c)1997, V. Levin

(defun C:CASE ( / ss ncase i n e txt txt1 l l1 nw)
  (setvar "cmdecho" 0)
  (graphscr)
  (prompt "\n Select text: ")
  (setq ss (ssget '((0 . "TEXT"))))
  (print)
  (if (not ss) (prompt "\n No text found."))
  (while ss
    (prompt "\n Change case of all letters to... ")
    (initget "Upper Lower Opposite Sentence Title None")
    (setq ncase (getkword "\n  ...Upper/Lower/Opposite/Sentence/Title/<None> :")
          i 0  tst 0
    )
    (if (= ncase "None") (setq ncase nil  ss nil))
    (if ncase
      (repeat (sslength ss)
        (setq e (entget (ssname ss i))  i (1+ i)
              txt (cdr (assoc 1 e))
              txt1 (cond
                     ((= ncase "Upper") (strcase txt))
                     ((= ncase "Lower") (strcase txt 1))
                     ((= ncase "Sentence")
                       (strcat (strcase (substr txt 1 1))
                               (strcase (substr txt 2) 1)
                       )
                     )
                     (T
                       (setq txt1 ""  nw nil  n 1)
                       (repeat (strlen txt)
                         (setq l (substr txt n 1)
                               l1 (strcase l
                                    (if (= ncase "Title")
                                      (if (and (> n 1) (not nw)) 1)
                                      (if (< 64 (ascii l) 91) 1)
                                    )
                                  )
                         )
                         (setq txt1 (strcat txt1 l1)  n (1+ n)
                               nw (if (and (= ncase "Title") (= l " ")) 1)
                         )
                       )
                       (eval txt1)
                     )
                   )
        )
        (entmod (subst (cons 1 txt1) (assoc 1 e) e))
      )
      (setq ss nil)
    )
    (print)
  )
  (princ)
)

(prompt "\n CASE - changes case of letters in selected lines of text.")
(princ)

t-bear

  • Guest
cHANGE cASE lISP
« Reply #1 on: November 12, 2003, 03:32:45 PM »
Nice!  Now how can we get it to work here in the forum?  I'm CONSTANTLY starting out my posts in upper case.  As I'm an HPHM typist, I don't notice it for about the first seven paragraphs....by the time I've re-typed it, I've lost mr train of thought!

NOTE: HPHM=Hunt & Peck, Hit & Miss........LOL

M-dub

  • Guest
cHANGE cASE lISP
« Reply #2 on: November 12, 2003, 03:50:19 PM »
LOL!
There's also a case changer in Microsoft's WORD.  If you had WAY too much to retype, copy everything you wrote, paste it into word and change the case...then, copy & paste it back in here.

t-bear

  • Guest
cHANGE cASE lISP
« Reply #3 on: November 12, 2003, 03:56:04 PM »
Yah, there's that.  But I'm spoiled by CAD...lisp is easier.... :?  Ah well, if you guys can put up with my "YELLING" I'll not worry to much..... :wink:

Eloquintet

  • Gator
  • Posts: 3206
cHANGE cASE lISP
« Reply #4 on: November 13, 2003, 12:16:33 PM »
I ALWAYS DO THAT TOO BEAR. I'VE OFTEN PONDERED THAT QUESTION. I MEAN UPPERCASE IS STANDARD IN OUR BUSINESS. I'M NOT YELLIN I'M JUST F....IN LAZY  :lol:

DAN
Dan

AutoCAD Architecture 2015

daron

  • Guest
cHANGE cASE lISP
« Reply #5 on: November 13, 2003, 12:19:07 PM »
I used to think that, but then I started writing code. For some reason it's easier on the eyes to read it in proper case, for me. But, being a typist, I don't have that problem.