Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Script Error — Can’t make type into type specifier?

I found an older script for Omnioutliner (below) to generate text statistics. I can't figure out how to fix the error. The result when I run the script is:


error "OmniOutliner got an error: Can’t make type into type specifier." number -1700 from type to specifier


Anyone have any thoughts?


Thanks.


-- Ver 0.7

-- Gives word count for: all rows, visible rows, selected rows,

-- and for each rich text column (and notes), as well as totals

-- Report dialog offers option of copying report to clipboard

-- (with datestamp and filename)



property pstrOfferCopy : "Copy report to clipboard"

property pDelim : space

property pEOL : return & return



on run

tell application id "com.omnigroup.OmniOutliner4"

try

activate

set oDoc to front document

on error

return

end try


-- Ensure that text item delimiter is SPACE

-- and prepare to restore any other value at the end of the script

set strDelim to my text item delimiters

set my text item delimiters to pDelim


tell front document

-- DEFINE SETS OF ROWS TO REPORT ON


-- All rows by default

set refAllRows to a reference to rows

set lngRows to count of refAllRows

set lstRowSets to {{"all", refAllRows}}


-- Plus visible rows if any are hidden

set refVisblRows to a reference to (rows where visible is true)

set lngVisible to count of refVisblRows

if lngVisible is not lngRows then ¬

set end of lstRowSets to {"visible", refVisblRows}


-- Plus selected rows if any are selected

set refSeldRows to a reference to selected rows

set lngSeldRows to count of refSeldRows

if lngSeldRows > 0 then ¬

set end of lstRowSets to {"selected", refSeldRows}


-- ASSEMBLE A LIST OF ALL RICH TEXT FIELDS (INCLUDING NOTES)

set refCols to a reference to (columns where type is rich text)

set lstColNames to name of refCols

if first item of lstColNames is "" then set first item of lstColNames to "Notes"

set lstColIDs to id of refCols

set lngCols to length of lstColIDs


-- COLLECT THE WORD COUNTS FOR ROW SETS & COLUMNS, WITH TOTALS

set lstData to {}

repeat with iRowSet from 1 to length of lstRowSets

set {strSetName, refSet} to item iRowSet of lstRowSets

set lstSet to {{strSetName, count of refSet}}

set intSetWords to 0

repeat with iCol from 1 to lngCols

-- Count words in this column

set strId to item iCol of lstColIDs

set lstColText to value of cell id strId of refSet

set intColWords to count of words of (lstColText as text)

-- Record the column name and word count

set end of lstSet to {item iCol of lstColNames, intColWords}

-- Increment the total word count

set intSetWords to intSetWords + intColWords

end repeat

set end of lstSet to {"total", intSetWords}

set end of lstData to lstSet

end repeat

end tell

end tell


-- BUILD A LEGIBLE REPORT FOR THE USER

set strMsg to ""

set intCols to (length of (first item of lstData)) - 1


-- A REPORT FOR EACH SET OF ROWS

repeat with iRowSet from 1 to length of lstData

set lstSetData to item iRowSet of lstData

set {strSetName, lngRows} to first item of lstSetData

set lngTotal to last item of last item of lstSetData

set strMsg to strMsg & lngTotal & pl(lngTotal, "word") & " in " & strSetName & " rows" & tab & "(" & lngRows & " " & pl(lngRows, "row") & ")" & return

-- WITH A SUB-REPORT FOR EACH RICH TEXT COLUMN (INCLUDING NOTES)

repeat with iCol from 2 to intCols

set {strColName, intColWords} to item iCol of lstSetData

set strMsg to strMsg & tab & strColName & ": " & intColWords & pl(intColWords, "word") & return

end repeat

set strMsg to strMsg & return

end repeat


set my text item delimiters to strDelim


tell me

activate

set recResponse to display dialog strMsg buttons {pstrOfferCopy, "OK"} with icon 1 with title ("WORD COUNT")

if button returned of recResponse is pstrOfferCopy then ¬

tell application id "com.apple.finder" to set the clipboard to ((current date) as string) & return & name of oDoc & return & return & strMsg

end tell

end run



-- Pluralize word unless lngQuant is 1

on pl(lngQuant, strWord)

if lngQuant is 1 then return " " & strWord

" " & strWord & "s"

end pl

MacBook Air (11-inch Mid 2013), OS X Yosemite (10.10.3), null

Posted on Apr 19, 2015 6:09 AM

Reply
5 replies

Apr 19, 2015 8:58 AM in response to CayGeeRay

You didn't specify (as far as I can see) where exactly the error happens in the script. We'd need to know that. But the type of error makes me thing that something in Omnioutliner's scripting dictionary got changed in one revision or another. Figure out what line the error occurs on, then check the scripting dictionary to make sure the script is using the kind of property or parameter the dictionary calls for.

Apr 20, 2015 5:46 AM in response to CayGeeRay

Hello


This is an educated guess.


Try replacing:


set refCols to a reference to (columns where type is rich text)



with:


set refCols to a reference to (columns where its type is rich text)



Because -


a) it is the only statement where term "type" appears in the script; and


b) if an object's property is also defined as a class, explicit "its" is required to access the property in order to resolve the ambiguity caused by terminology conflict.


E.g.,


tell application id "com.apple.TextEdit" if not (exists document 1) then make new document return window 1 whose document = document 1 --> error "TextEdit got an error: Can’t make document into type reference." number -1700 from document to reference end tell tell application id "com.apple.TextEdit" if not (exists document 1) then make new document return window 1 whose its document = document 1 --> OK end tell




Tested with OS X 10.6.8.


Good luck,

H

Script Error — Can’t make type into type specifier?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.