2015-02-04 6 views
0

TextWrangler의 공백을 무시하고 두 문서를 비교할 방법을 찾고있었습니다. TextWrangler의 인터페이스가이 옵션을 제공하지는 않지만 https://groups.google.com/d/msg/bbedit/ER3VdOf2xOs/IcKi3ccA90oJTextWrangler : AppleScript로 공백을 무시한 두 문서 비교

이제는 완전히 작동하는 해결책이 아니 었습니다. 이 스크립트는 다음과 같습니다 :

tell application "TextWrangler" 
    compare document 1 against document 2 options ¬ 
     {case sensitive:true, ignore curly quotes:true, ignore extra spaces:true, ignore leading spaces:true, ignore trailing spaces:true} 
end tell 

작품은 다소 유연하지 않습니다. 그래서 나는 두 번째 스텁 작업 만들려고 :

set compOpts to {"All Options:false", "case sensitive:true", "ignore curly quotes:true", "ignore extra spaces:true", "ignore leading spaces:true", "ignore trailing spaces:true"} 

tell application "TextWrangler" 

    tell me to set compOpts to choose from list compOpts ¬ 
     with title "Compare Front Two Documents" with prompt ¬ 
     "Select Options" default items (items 2 thru -1 of compOpts) ¬ 
     multiple selections allowed true ¬ 
     with empty selection allowed 

    display dialog compOpts as string 

    set compareOptions to make new Compare Options with properties compOpts 

    compare document 1 against document 2 options compareOptions 

end tell 

을 그러나 여기에서 나는 오류를 얻을 : 내가 잘못 여기서 뭐하는 거지

error "TextWrangler got an error: Can’t make class Compare Options." number -2710 from Compare Options to class 

?

나는 다음 스크립트는 작동 추가 할 :

tell application "TextWrangler" 
    set compareOptions to ¬ 
     {case sensitive:true, ignore curly quotes:true, ignore extra spaces:true, ignore leading spaces:true, ignore trailing spaces:true} ¬ 

    compare document 1 against document 2 options compareOptions 

end tell 

하지만이 작동하지 않습니다

set compareOptions to {All Options:false, case sensitive:true, ignore curly quotes:true, ignore extra spaces:true, ignore leading spaces:true, ignore trailing spaces:true} 

그냥 컴파일되지 않습니다. 뭐야 ...?

답변

1

이 옵션은 TextWrangler에게만 알려져 있기 때문에 TextWrangler tell 블록에서 만들어야합니다. 옵션의 문자열 표현에서 옵션을 작성할 수 없으므로 목록에서 선택하려는 경우 선택한 문자열에서 동적으로 작성해야합니다. 내가 어떻게했는지 한번보세요.

행운을 빈다.

set compOptsList to {"All Options:false", "case sensitive:true", "ignore curly quotes:true", "ignore extra spaces:true", "ignore leading spaces:true", "ignore trailing spaces:true"} 

set compOpts to choose from list compOptsList ¬ 
    with title "Compare Front Two Documents" with prompt ¬ 
    "Select Options" default items (items 2 thru -1 of compOptsList) ¬ 
    multiple selections allowed true ¬ 
    with empty selection allowed 

tell application "TextWrangler" 
    set chosenOptions to {} 

    repeat with i from 1 to count of compOpts 
     set thisOption to item i of compOpts 

     if thisOption is item 2 of compOptsList then 
      set chosenOptions to chosenOptions & {case sensitive:true} 
     else if thisOption is item 3 of compOptsList then 
      set chosenOptions to chosenOptions & {ignore curly quotes:true} 
     else if thisOption is item 4 of compOptsList then 
      set chosenOptions to chosenOptions & {ignore extra spaces:true} 
     else if thisOption is item 5 of compOptsList then 
      set chosenOptions to chosenOptions & {ignore leading spaces:true} 
     else if thisOption is item 6 of compOptsList then 
      set chosenOptions to chosenOptions & {ignore trailing spaces:true} 
     end if 
    end repeat 

    if chosenOptions is not {} then 
     compare document 1 against document 2 options chosenOptions 
    else 
     compare document 1 against document 2 
    end if 
end tell 
+0

코드는 매력처럼 작동합니다. 그래서 내가 아는 중요한 점은 옵션의 문자열 표현을 TextWrangler의 Compare Options 클래스로 변환 할 수 없다는 것입니다. 당신의 대답이 좋기 때문에 나는 그것을 투표하고 싶습니다. 그러나 그렇게 할 평판이 없어서 미안 해요! –