4 Replies Latest reply on May 13, 2008 1:52 AM by kindaian

    String Manipulation Question

    Mitch Wallace Level 1
      How do you change the case of a text string to upper or lower with lingo? Sorry if I'm missing something obvious in the help panel but I just seem to be going in circles looking for it.
        • 1. Re: String Manipulation Question
          Level 7
          The ASCII code for each lower case is 32 away from it's equivalent upper
          case letter. For example the code for "a" is 97 and the code for "A" is 65.

          So,

          num = charToNum ("a")
          num = num - 32
          newChar = charToNum (num)

          Of course, I would create a function that would loop through a word to
          convert it. There's a lot of functionality you could add into a funtion so
          you'd only have to write it once and could use it generically.


          "Mitch Wallace" <webforumsuser@macromedia.com> wrote in message
          news:fvvcgg$k05$1@forums.macromedia.com...
          > How do you change the case of a text string to upper or lower with lingo?
          > Sorry if I'm missing something obvious in the help panel but I just seem
          > to be going in circles looking for it.


          • 2. Re: String Manipulation Question
            Level 7
            If you are using DMX 2004 or D11, and can use javascript syntax, then
            make this as a JS moviescript...

            //START HERE//
            function stringToLower(vText){
            return vText.toLowerCase();
            }

            function stringToUpper(vText){
            return vText.toUpperCase();
            }
            //END HERE//

            Once you have that in, then you can use these functions from Lingo:


            put stringToLower("HI THere123")
            -- "hi there123"

            put stringToUpper("HI THere123")
            -- "HI THERE123"
            • 3. Re: String Manipulation Question
              Mitch Wallace Level 1
              Thanks guys. I had just assumed that Lingo would would have some simple single word commands for this, like some of the other programs I use. Last night figured out the ASCII code shift amount and ended up doing exactly what you guys suggested here and wrote a couple of little functions to switch the case of the text.
              • 4. Re: String Manipulation Question
                kindaian
                If you use lingo you can do:

                on toLowerCase inString
                p = newObject("String", inString)
                return p.toLowerCase()
                end

                Which uses a "flash" object... from what i've read in another place... (i wonder what other kinds of "functionality" on can piggyback from flash/objects this way hehehe)