コメント、ありがとうございます。
ご指摘のコードにおけるエラーの原因は、変数spaceJ_countの定義漏れにあるかと思います。
修正案(★部)を下記に示します。また、ご要望のタブのカウントにつきましても補足(●部)いたしましたので、参考にしていただければ幸いです。
--
on run
tell application "TextEdit"
set theText to the text of (the clipboard)
set word_count to count words of (the clipboard)
set char_count to count characters of (the clipboard)
set para_count to count paragraphs of (the clipboard)
end tell
set theLF to ASCII character 10
set LF_count to countSubstring(theText, theLF)
set theTAB to ASCII character 9 --●
set TAB_count to countSubstring(theText, theTAB) --●
set space_count to countSubstring(theText, " ")
set spaceJ_count to countSubstring(theText, " ") --★
set show_words to "文字数:" & (char_count as string) & return & "改行を除いた文字数:" & ((char_count - LF_count) as string) & return & "空白、改行を除いた文字数:" & ((char_count - space_count - spaceJ_count - TAB_count - LF_count) as string) & return & "行数:" & (para_count as string) --★●
tell application "TextEdit" --表示の改善
display dialog show_words with icon 1 buttons {"OK"} default button "OK"
end tell
end run
-- e.g. countSubstring("abc abc abc", "abc") --> 3
on countSubstring(theText, theSubstring)
(略)
end countSubstring
--
注意:本スクリプトで得られた結果の正当性の評価は行っておりませんので、予めご了承下さい。
補足ですが、高度な文字列の処理をご要望のようですので、下記が参考になるかと思います。
http://ja.wikipedia.org/wiki/Perl
http://ja.wikipedia.org/wiki/正規表現
お役に立てれば幸いです。