Skip to content

Instantly share code, notes, and snippets.

@milligramme
Created February 3, 2014 10:13
Show Gist options
  • Select an option

  • Save milligramme/8781387 to your computer and use it in GitHub Desktop.

Select an option

Save milligramme/8781387 to your computer and use it in GitHub Desktop.
#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