• 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
Re: Compare two AppleScripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compare two AppleScripts


  • Subject: Re: Compare two AppleScripts
  • From: Nigel Garvey <email@hidden>
  • Date: Sat, 28 Apr 2018 11:02:10 +0100

Shane Stanley wrote on Sat, 28 Apr 2018 09:29:49 +1000:

>FWIW, this is what I use:
>
>try
>       tell application "Script Debugger"
>               set script2 to (source text of document 2) as text
>               set script1 to (source text of document 1) as text
>       end tell
>on error -- not two scripts open
>       beep
>end try
>tell application "BBEdit"
>       make new text window with properties {contents:script2}
>       make new text window with properties {contents:script1}
>       set theDiff to compare text window 1 against text window 2 options
{case sensitive:true, ignore leading spaces:true, ignore trailing
spaces:true,
>ignore extra spaces:false}
>       beep
>       set foundDiff to differences found of theDiff
>end tell
-- etc.

Since the source code of compiled scripts can contain both linefeeds and
returns (such as happens in scripts beginning with multi-line block
comments), which can confuse BBEdit/TextWrangler, it seems a good idea
to homogenise line endings first:

  try
    set astid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to linefeed -- or to return or to
return & linefeed. It doesn't matter which.
    tell application "Script Debugger"
      set script2 to (get source text of document 2)'s paragraphs as text
      set script1 to (get source text of document 1)'s paragraphs as text
    end tell
    set AppleScript's text item delimiters to astid
  on error -- not two scripts open
    set AppleScript's text item delimiters to astid
    beep
  end try
  tell application "BBEdit"
    activate
    make new text window with properties {contents:script2}
    make new text window with properties {contents:script1}
    set theDiff to compare text window 1 against text window 2 options {case
sensitive:true, ignore leading spaces:true, ignore trailing spaces:true, ignore
extra spaces:false}
    beep
    set foundDiff to differences found of theDiff
  end tell


NG

 _______________________________________________
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: Compare two AppleScripts
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Compare two AppleScripts
  • Next by Date: Re: Compare two AppleScripts
  • Previous by thread: Re: Compare two AppleScripts
  • Next by thread: Re: Compare two AppleScripts
  • Index(es):
    • Date
    • Thread