On Sep 26, 2006, at 6:40 PM, Cortesi wrote:
OK, something simpler. Scripting. Finding parts of a document and
noting their positions.
if I run --
tell application "BBEdit"
find Some_Literal searching in text document 1 options {search
mode:literal, starting at top:true} with selecting match
end tell
-- afterward the sought text is selected, and the result of the
find includes the "found object" reference value, like:
found object:characters 9774 thru 9798 of text document 1 of
application "BBEdit"
Or, if I just ask BBEdit for "the selection" it will give me the
same kind of reference (characters 9774 thru 9798 of text document
1 of application "BBEdit")
The stupid problem I am having is that I want to capture that
number (9774) and use it later -- but I can't find how to get
Applescript to give me access to the elements of a reference.
Anything I do with "found object of the result" gets me the
referent value, the found string. Like, asking for "word 2 of
found object of the result" gets me the second word of the found
text itself. I understand WHY it happens, but how do I get around it?
The found object is a record -- you need to use field accessor
notation to get its properties.
If you do this is Script Editor
tell application "BBEdit"
activate
find "Product" searching in text 1 of text document 1 options
{search mode:literal, starting at top:true} with selecting match
properties of found object of result
end tell
You will see in the results window
{id:missing value, container:text window 1 of application "BBEdit",
contents:"product", length:7, characterOffset:65, startLine:4,
endLine:4, startColumn:6, endColumn:13, startDisplayLine:4,
endDisplayLine:4}
So:
set found_result to found object of (find "Product" searching in
text 1 of text document 1 options {search mode:literal, starting at
top:true})
startColumn of found_result -- returns 9
endColumn of found_result -- returns 16
etc.
Regards,
Neil Faiman
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>