[X4U] Need Script Editing Advice

Lars Bertelsen lbe at mac.com
Sun Feb 4 11:20:24 PST 2007


In stead of (count words of _str) try length(_str) or mayby size(_str).
If you look in the documentation you'll be sure to find some place 
where they discuss string operations; you can find the exact syntax 
there!
NB! The above will count everything including spaces. tabs and linefeeds.
If you don't want that, you'll need to filter oust som of the stuff 
you don't need. For this, look for a replace() or replaceall() 
command. I don't know if APplescript has that (it didn't used to!), 
but maybe it has been included now. Otherwise use google to find some 
code that will do it for you! It is definitely out there. In 
principle, what you want is to say something like:
_str=replace(_str," ","")
//space
_str=replace(_str,char(13),"");
_str=replace(_str,char(10),"");
//the two newline characters
_str=replace(_str,char(9),"");
//tab I believe
display alert "Word count: " & length(_str);


Again, the syntax is almost certainly not correct, but the principle applies!

Lars Bertelsen



>I saw on Daring Fireball the script below that does a word count in
>conjunction with ThisService, and want to edit it, so it counts
>characters. Can anyone tell me what to edit/substitute? Thanks in advance!
>
>
>on process(_str)
>	tell application "System Events"
>		set _appname to name of first process whose frontmost is true
>	end tell
>	tell application _appname
>		display alert "Word count: " & (count words of _str)
>	end tell
>end process
>
>_______________________________________________
>X4U mailing list
>X4U at listserver.themacintoshguy.com
>http://listserver.themacintoshguy.com/mailman/listinfo/x4u
>
>Listmom is trying to clean out his closets! Vintage Mac and random stuff:
>          http://search.ebay.com/_W0QQsassZmacguy1984


-- 



More information about the X4U mailing list