Counting Chars by ASCI Values
Jim Ault
JimAultWins at yahoo.com
Tue Feb 28 16:49:30 EST 2006
On 2/28/06 1:27 PM, "Todd Geist" <tg.lists at geistinteractive.com> wrote:
> I need to count the number of times a Character occurs in text
> string. The character will be high or Low ASCII. SO I need to input
> the value as an ASCII value.
>
> Anybody have any scripts that can get me started?
>
Perhaps you could try setting that char as the itemdel and getting the
number of items. Caution: note that the last char of the string could be a
hit, so you need to pad the string with one extra char to be accurate.
--make a new stack, paste the following into the stack script, dblclk
on mouseDoubleUp
put "a" into hitt
put "anohtalj az aja ljala a" into txt
set the itemdel to hitt
get the number of items in (txt&hitt)
answer it-1
delete char -1 of txt
get the number of items in (txt&hitt)
answer it-1
--"¼"
put "¼" into hitt
put "anohtalj ¼az aja ljala ¼ a¼" into txt
set the itemdel to hitt
get the number of items in (txt&hitt)
answer it-1
delete char -1 of txt
get the number of items in (txt&hitt)
answer it-1
end mouseDoubleUp
Jim Ault
Las Vegas
More information about the use-livecode
mailing list