Re: Compare two AppleScripts
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