Created
February 3, 2014 10:13
-
-
Save milligramme/8781387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #target "InDesign" | |
| var doc = app.documents[0], fn, fn_string; | |
| fn = function () { alert(new Date().getFullYear() >= 2020 ? "○○○○○" : "◆◆◆◆◆") }; | |
| try { | |
| doc.insertLabel("function", fn); | |
| } | |
| catch(e){ | |
| $.writeln(e); | |
| // => エラー: メソッド「insertLabel」のパラメーター「value」の値が無効です。予想される値は String ですが、値 function data を受け取りました。 | |
| } | |
| finally { | |
| fn_string = fn.toString(); | |
| doc.insertLabel("function", fn_string); | |
| eval("(" + doc.extractLabel("function") + ")();"); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment