script for Apple Works 5

I am a novice scripter who needs help converting the word or character count in Apple Works 5 into column inches of copy for a newspaper. Where is the hook for that count function so I can divide it by the characters or words in one of our inches?

Alas, I don’t have Appleworks 5 (I have 4 & 6), so I can’t answer directly. Plus, I don’t understand your question. If you’d post your non-working script, I’m sure everyone here will be glad to help.

I tried the script, and if you select all the text in the document it hangs on the word number on the next line of code. It says every word of ClarisWorks(AppleWorks) does not understand count message.

“I tried the script, and if you select all the text in the document it hangs on the word number on the next line of code. It says every word of ClarisWorks(AppleWorks) does not understand count message. "
Yes. The command is being directed to the wrong object. I don’t have AW5 to test, and there have been changes in the applescript support between it and AW6, which better supports the object model.
I suggest trying two things:
change “number” to “count” (probably won’t make any difference” as in set word_count to count of words of selection
and after the line " if front document exists then" put “tell document 1” before the last “end tell” put another “end tell.” This should direct the command to proper object.

I tried what you suggested, count is in the ClarisWorks dictionary, and I think I have the syntax correct, but I am not sure. I don’t know that much about AppleScript, so I keep trying until it works(or give up). here is what it looks like now (kinda familliar though):

tell  application "ClarisWorks" -- or AppleWorks, since they should be one in the same
  if front document exists then
    --tell document 1
      if length of the selection > 0 then-- there is a selection
        set word_count to count each word of document 1 --get the same error with selection-- why not characters, as below?
        set myinches to word_count-- math for coverting words to inches???
        set mymessage to "Selection from "" & (name of front document) & """ & " contains " & word_count & " words."
      else-- there isn't a selection
        set Character_count to number of characters of front document -- all characters in front doc
        set myinches to characters 1 thru 8 of ((Character_count / 245) as text) -- change not required
        set mymessage to """ & (name of front document) & """ & " contains " & myinches & " Inches."
      end if
   -- end tell
  else
    set mymessage to "There is no open document."
  end if
-- show the result
display dialog mymessage buttons {"OK"} --default button "OK" with icon note
end tell

the error I get is:
ClarisWorks can’t continue count

tell document 1 is a comment because I put it in and it didn’t seem to work, but I wanted the option to still be present.

I borrowed a copy of Clarisworks 5 and tested it.
When the selection is an entire paragraph then

tell application "ClarisWorks"
set x to the selection
--
-- paragraph 8 of text body of document "untitled"
-- of application "ClarisWorks"
--
set y to contents of x
count of words in y
--
-- 17 in the document I tested
--
end tell

works.
but when the selection is some portion of text

tell application "ClarisWorks"
set x to the selection
--
-- text from word 52 to word 53 of text body
-- of document "untitled" of application "ClarisWorks"
--
set y to contents of x -- "contents of x" fails
count of words in y -- never executed
end tell

Contents of x shouldn’t fail. I have no suggestions for a work-around. It’s not right that the object returned by the selection isn’t recognized by Clarisworks.
the true object should be words 52 thru 53 of text body document “untitled” of application “ClarisWorks”.
It also fails for multiple paragraph selection:
text from paragraph 8 to paragraph 10 of text body of document “untitled” of application “ClarisWorks”
once again, the right form is “paragraphs 8 thru 10…”