3 Replies Latest reply on Aug 25, 2006 7:10 AM by Newsgroup_User

    how count the spaces in the sentences?

    farhanakhan Level 1
      hi
      guys
      i m very happy fromthis forum coz i get a lot solution from this forum

      now i want to coutn the spaces in the sentences tell me how
      like this
      vision international

      --1 space
        • 1. Re: how count the spaces in the sentences?
          Level 7
          If you assume that there are no double spaces

          str = "vision international"
          numberOfSpaces = str.word.count - 1
          put numberOfSpaces

          If you don't assume that

          str = "vision international"

          cnt = 0
          numChars = str.length
          repeat with x = 1 to numChars
          if str.char [x] = SPACE then
          cnt = cnt + 1
          end if
          end repeat
          put cnt


          --
          Craig Wollman
          Word of Mouth Productions

          phone 212 928 9581
          fax 212 928 9582
          159-00 Riverside Drive West #5H-70
          NY, NY 10032
          www.wordofmouthpros.com


          "farhanakhan" <webforumsuser@macromedia.com> wrote in message
          news:ecmdqb$oh9$1@forums.macromedia.com...
          > hi
          > guys
          > i m very happy fromthis forum coz i get a lot solution from this forum
          >
          > now i want to coutn the spaces in the sentences tell me how
          > like this
          > vision international
          >
          > --1 space


          • 2. Re: how count the spaces in the sentences?
            Minds Eye
            As with the reply to your other post, you can do this using our String Handler Xtra
            http://www.the-mindseye.co.uk/prog/string_handler.shtml

            There is one function for swapping substrings mevcReplaceSubstr
            It returns the number of substrings it has replaced. So all you have to do is get it to swap a space for a space and it will return the number of spaces in the string.

            oStr = new(xtra "MevString", "i m working in the vision internation company")
            put oStr.mevcReplaceSubstr(" "," ")
            -- 7

            Give it a go - It's FREE!!!

            Regards,
            Trev
            • 3. Re: how count the spaces in the sentences?
              Level 7
              I don't have Director in front of me right now, but I think this should
              tell you how many spaces you have:

              _player.itemDelimiter = SPACE
              NumSpaces = member("someText").text.item.count - 1



              Dave