JavaScript を実行

2025年11月25日 (火) 19:07時点におけるMSY-07 (トーク | 投稿記録)による版 (オブジェクト名の修正(マクロリファレンス:3:OutputBar オブジェクトを参照))
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)

選択範囲をevalして結果をその場に出します。電卓代わりにどうぞ。

置き換え版 編集

// JavaScriptを実行 (置き換え版).js

if (document.selection.IsEmpty) {
  document.selection.EndOfLine(false, mePosLogical);
  document.selection.StartOfLine(true, mePosLogical);
}
if (document.selection.Text) {
  document.selection.Text = eval(document.selection.Text);
}

挿入版 編集

// JavaScriptを実行.js (挿入版)

if (document.selection.IsEmpty) {
  document.selection.EndOfLine(false, mePosLogical);
  document.selection.StartOfLine(true, mePosLogical);
}

if (document.selection.Text) {
  document.selection.Text = document.selection.Text + ' => ' + eval(document.selection.Text);
}

アウトプットバー版 編集

// JavaScriptを実行 (アウトプットバー版).js

if (document.selection.IsEmpty) {
  document.selection.EndOfLine(false, mePosLogical);
  document.selection.StartOfLine(true, mePosLogical);
}

if (document.selection.Text) {
  outputBar.visible = true;
  // outputBar.Writeln(">> " + document.selection.Text);
  outputBar.Writeln("=> " + eval(document.selection.Text).toString());
}
スポンサーリンク