(*
This Applescript lets you do a search starting at the top of the current document, NOT where the cursor is currently positioned
Author: Ryan Wilcox
Date: June 17, 2014
License: Public Domain
*)
tell application "BBEdit"
set theChoice to display dialog "Search current document for:" default answer PREV_SEARCH_STRING
if button returned of theChoice is "OK" then
set searchOpt to {starting at top:true, wrap around:false}
set oldSearchString to text returned of res
tell window 1
set findRes to find (text returned of res) options searchOpt with selecting match
if findRes's found is false then beep
end tell
end if
end tell
set PREV_SEARCH_STRING to current search strings
set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING
set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING
tell application "BBEdit"
set PREV_SEARCH_STRING to current search strings
set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING
set theChoice to display dialog "Search current document for:" default answer PREV_SEARCH_STRING
if button returned of theChoice is "OK" then
set searchOpt to {starting at top:true}
tell window 1
set findRes to find text returned of theChoice options searchOpt with selecting match
if findRes's found is false then beep
set search string of current search strings to findRes
end tell
end if
end tell
property startAtTop : true
property wrapAround : false
property caseSensitive : false
property matchWords : false
-----------------------------------------------------------------------------
tell application "BBEdit"
--------------------------------- set prev search string
set prevSearchString to current search strings
try -- prev search string not always exists
set prevSearchString to search string of prevSearchString
on error
set prevSearchString to ""
end try
-------------------------------- perform search
set theChoice to display dialog "Search current document for:" default answer prevSearchString
if button returned of theChoice is "OK" then
set searchOpt to {starting at top:startAtTop, wrap around:wrapAround, backwards:false, case sensitive:caseSensitive, match words:matchWords}
tell window 1
set findRes to find text returned of theChoice options searchOpt with selecting match
if findRes's found is false then beep
--set search string of current search strings to findRes -- seems uselessI can't seem to directly:
set PREV_SEARCH_STRING to search string of PREV_SEARCH_STRING
On Feb 5, 2018, at 11:44, Christopher Stone <listm...@suddenlink.net> wrote:Under some circumstances you have to expand the property before you can get to the sub-properties:
How can one know in which case that it is necessary?