「JavaScript を実行」の版間の差分

提供: MeryWiki
ナビゲーションに移動 検索に移動
編集の要約なし
MSY-07 (トーク | 投稿記録)
オブジェクト名の修正(マクロリファレンス:3:OutputBar オブジェクトを参照)
 
(3人の利用者による、間の5版が非表示)
1行目: 1行目:
選択範囲をevalして結果をその場に出します。電卓代わりにどうぞ。
選択範囲をevalして結果をその場に出します。電卓代わりにどうぞ。


== 置き換え版 ==
<syntaxhighlight lang="javascript" copy>
// JavaScriptを実行 (置き換え版).js


挿入版
if (document.selection.IsEmpty) {
<source lang="javascript">
  document.selection.EndOfLine(false, mePosLogical);
// JavaScriptを実行.js
  document.selection.StartOfLine(true, mePosLogical);
}
if (document.selection.Text) {
  document.selection.Text = eval(document.selection.Text);
}
</syntaxhighlight>
 
== 挿入版 ==
<syntaxhighlight lang="javascript" copy>
// JavaScriptを実行.js (挿入版)
 
if (document.selection.IsEmpty) {
  document.selection.EndOfLine(false, mePosLogical);
  document.selection.StartOfLine(true, mePosLogical);
}


if (document.selection.Text) {
if (document.selection.Text) {
   document.selection.Text = document.selection.Text + ' => ' + eval(document.selection.Text)
   document.selection.Text = document.selection.Text + ' => ' + eval(document.selection.Text);
}
}
</source>
</syntaxhighlight>
 
== アウトプットバー版 ==
<syntaxhighlight lang="javascript" copy>
// JavaScriptを実行 (アウトプットバー版).js


置き換え版
if (document.selection.IsEmpty) {
<source lang="javascript">
  document.selection.EndOfLine(false, mePosLogical);
// JavaScriptを実行.js
  document.selection.StartOfLine(true, mePosLogical);
}


if (document.selection.Text) {
if (document.selection.Text) {
   document.selection.Text = eval(document.selection.Text)
   outputBar.visible = true;
  // outputBar.Writeln(">> " + document.selection.Text);
  outputBar.Writeln("=> " + eval(document.selection.Text).toString());
}
}
</source>
</syntaxhighlight>

2025年11月25日 (火) 19:07時点における最新版

選択範囲を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());
}
スポンサーリンク