2014-09-16 2 views
0

OmniGraffle 5.3.6을 스크립팅하려고하는데 canvaslayers 요소를 읽으려고합니다. AppleScript로 함수 (또는 처리기)를 전달했습니다. 나는 다음과 실행하면 :참조로 전달 된 값의 속성을 읽는 방법은 무엇입니까?

on exportToPng(theCanvas) 
    set layerCount to count of layers of theCanvas 
end exportToPng 

tell application "OmniGraffle Professional 5" 
    set theDocument to front document 
    set allCanvases to canvases of theDocument 
    set theCanvas to item 1 of allCanvases 
    my exportToPng(theCanvas) 
end tell 

내가받을 다음과 같은 오류가 : 내 함수를 인라인한다면

error "OmniGraffle Professional 5 got an error: Can’t make |layers| of 
    canvas id 1 of document \"base-dependency-diagram.graffle\" into type reference." 
    number -1700 from |layers| of canvas id 1 of document 
    "base-dependency-diagram.graffle" to reference 

그러나, 다음 모든 작동합니다 :

tell application "OmniGraffle Professional 5" 
    set theDocument to front document 
    set allCanvases to canvases of theDocument 
    set theCanvas to item 1 of allCanvases 
    set layerCount to count of layers of theCanvas 
end tell 

내가 읽은 Passing by Reference Versus Passing by Value,하지만 도움이되지 않았습니다. 꽤 희박합니다.

답변

1

참조로 전달할 수 있습니다. 그러나 전달할 때마다 응용 프로그램이 전달 된 참조를 처리 할 수 ​​있도록 "응용 프로그램에 알리기"가 있어야합니다. 그래서이 같은 함수 ... 결국

on exportToPng(theCanvas) 
    tell application "OmniGraffle Professional 5" 
     set layerCount to count of layers of theCanvas 
    end tell 
end exportToPng 

만 "OmniGraffle 전문 5"를 원할 것입니다 theCanvas에서 레이어를 얻는 방법을 알고있다.

관련 문제