• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Script Debugger 5: Find Next Marker
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Script Debugger 5: Find Next Marker


  • Subject: Script Debugger 5: Find Next Marker
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 14 Sep 2012 07:22:54 -0500

Hey Folks,

One of the things I've wanted for ages in Script Debugger is the ability to set a marker and go to it.

I really dislike having to manually find my place again.

Enter Script Debugger's character range property of the selection and the trusty Satimage.osax.

This script defaults to finding SD's native marker '--»', but you can set it to anything you like.

The script will find the next marker character(s).  It will wrap if needed.  It will fail silently if there is no marker in the script.

The next thing to do is to write a script to emplace a temporary mark like '--» ••••••••••'.  The advantage of this string is that it can be seen from navigation pop-up menu in addition to the find-mark script.

So I'll have one script to navigate to the next mark and another to navigate to a temporary mark (so I can easily save my place).

I guess I need to write another script to navigate backwards, but that'll have to wait for another day.

--
Best Regards,
Chris

---------------------------------------------------------------------
#       Author: Christopher Stone <email@hidden>
#      Created: 2012-09-14 : 06:55
#     Modified: 2012-09-14 : 07:16
#  Application: Script Debugger
#      Purpose: Find the next Marker
# Dependencies: Satimage.osax
---------------------------------------------------------------------
on fnd(findStr, srcData, startPos, caseSensitive, allOccurrences, stringResult)
  try
    set findResult to find text findStr in srcData ¬
      starting at startPos ¬
      case sensitive caseSensitive ¬
      all occurrences allOccurrences ¬
      string result stringResult ¬
      with regexp
    return findResult
  on error
    return false
  end try
end fnd
---------------------------------------------------------------------
on fndBool(findStr, srcData, caseSensitive, allOccurrences, stringResult)
  try
    set findResult to find text findStr in srcData ¬
      case sensitive caseSensitive ¬
      all occurrences allOccurrences ¬
      string result stringResult ¬
      with regexp
    return true
  on error
    return false
  end try
end fndBool
---------------------------------------------------------------------
try
  set _mark to "--»"
  tell application "Script Debugger"
    if document 1 exists then tell document 1
      set _SRC to source text
      if (fndBool(_mark, _SRC, false, false, false) of me) = true then
        try
          set {startPos, null} to character range of selection
          set fRec to fnd(_mark, _SRC, startPos, false, false, false) of me
          set selection to {(matchPos of fRec) + 1, matchLen of fRec}
        on error
          set startPos to 1
          set fRec to fnd(_mark, _SRC, startPos, false, false, false) of me
          set selection to {(matchPos of fRec) + 1, matchLen of fRec}
        end try
      end if
    end tell
  end tell
on error eMsg number eNum
  # stdErrAS(eMsg, eNum, true, true) of me
  stdErrAS(eMsg, eNum, true, false) of me
end try
---------------------------------------------------------------------

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Script Debugger 5: Find Next Marker Rev2
      • From: Christopher Stone <email@hidden>
    • Re: Script Debugger 5: Find Next Marker
      • From: Christopher Stone <email@hidden>
  • Prev by Date: List Current MacUpdate Items
  • Next by Date: Re: Script Debugger 5: Find Next Marker
  • Previous by thread: Re: List Current MacUpdate Items
  • Next by thread: Re: Script Debugger 5: Find Next Marker
  • Index(es):
    • Date
    • Thread