• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie. How do I count "i"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie. How do I count "i"?


  • Subject: Re: Newbie. How do I count "i"?
  • From: "Marc K. Myers" <email@hidden>
  • Date: Sat, 26 Jan 2002 15:12:09 -0500
  • Organization: [very little]

> Date: Sat, 26 Jan 2002 11:47:30 +0100
> Subject: Newbie. How do I count "i"?
> From: Steen <email@hidden>
> To: <email@hidden>
>
> Hello.
>
> I hope someone can tell me how I can count every "i" in z.
> I have been looking everywhere to find the solution.
>
> set z to "ideas how to do this?"
> count every character = "i" in z
>
> When I do this I get an error.
>
> Any help with this at will be greatly appreciated.

set z to "Now is the time for all good men to come to the aid of the party!"
cntChar(z, "i")

on cntChar(theText, theChar)
try
set theText to (theText as text)
on error
display dialog "That's not text!"
return
end try
set {od, AppleScript's text item delimiters} to [optn-L]
{AppleScript's text item delimiters, {theChar}}
set charCnt to (count (text items of theText)) - 1
set AppleScript's text item delimiters to od
return charCnt
end cntChar

Note that "[optn-L]" stands in for AppleScript's continuation character.

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[1/26/02 3:11:00 PM]


  • Prev by Date: Re: Save Me
  • Next by Date: Re: solutions to scripting addition terminology confilicts
  • Previous by thread: Re: Newbie. How do I count "i"?
  • Next by thread: Re: Newbie. How do I count "i"?
  • Index(es):
    • Date
    • Thread