STRCASE

Discussion in 'AutoCAD' started by GaryDF, Oct 5, 2004.

  1. GaryDF

    GaryDF Guest

    I know about the following, my question is;
    Is there a way to get "Hello" string?

    Gary

    Command: (strcase "Hello")
    "HELLO"
    Command: (strcase "HELLO" T)
    "hello"
     
    GaryDF, Oct 5, 2004
    #1
  2. GaryDF

    David Bethel Guest

    (setq str "hello")

    (strcat (strcase (substr str 1 1)) (strcase (substr str 2) t))

    -David
     
    David Bethel, Oct 5, 2004
    #2
  3. GaryDF

    GaryDF Guest

    Thanks

    Gary

     
    GaryDF, Oct 5, 2004
    #3
  4. GaryDF

    GaryDF Guest

    I cut code from Peter Jamtgaard's routine to set text to title setting for
    the first character of each word to upper case and all others lower case.

    This only returns the first word's letter as a capital letter.
    (strcat (strcase (substr str 1 1)) (strcase (substr str 2) t))


    (setq STRNEW "BRICK LEDGE")

    The code below will return:

    "Brick Ledge"

    (defun TitleTx (/ ncase i txt txt1 nw n l l1)
    (setq NCASE "T")
    (setq I 0)
    (setq
    I (1+ I)
    TXT STRNEW
    TXT1 (cond
    (T
    (setq TXT1 ""
    NW nil
    N 1
    )
    (repeat (strlen TXT)
    (setq L (substr TXT N 1)
    L1 (strcase
    L
    (if (= NCASE "T")
    (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 "T") (= L " "))
    1
    )
    )
    )
    (eval TXT1)
    )
    )
    )
    (setq STRNEW TXT1)
    (princ)
    )

    Gary
     
    GaryDF, Oct 5, 2004
    #4
  5. GaryDF

    David Bethel Guest

    The first letter in each word in a different scenario than you first
    described. You wold need to define and search for the deliminator
    spaces in the string and then feed the remaining string to the call. -David
     
    David Bethel, Oct 6, 2004
    #5
  6. GaryDF

    BillZ Guest

    If your words were a list of strings:

    (mapcar '(lambda (x)(strcat (strcase (substr x 1 1))(strcase (substr x
    2) t)))(list "string" "hello" "goodbye"))

    ("String" "Hello" "Goodbye")

    Bill
     
    BillZ, Oct 6, 2004
    #6
  7. GaryDF

    GaryDF Guest

    Thanks

    Gary
     
    GaryDF, Oct 6, 2004
    #7
  8. GaryDF

    GaryDF Guest

    I changed my dirrection in mid stream, sorry.
    This is what I was after:
    all caps, all lower case, title and only first char

    Gary
     
    GaryDF, Oct 6, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...