「ファイル(選択範囲)の仮保存」の版間の差分

提供: MeryWiki
ナビゲーションに移動 検索に移動
MSY-07 (トーク | 投稿記録)
ハイライト効果の適用
MSY-07 (トーク | 投稿記録)
日付のフォーマットを変更
4行目: 4行目:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// saveAstemporary.js
// saveAstemporary.js
// 2013/01/19
// 2013-01-19


var s = Editor.ActiveDocument.Selection.Text;
var s = Editor.ActiveDocument.Selection.Text;

2024年9月3日 (火) 19:14時点における版

  • 選択範囲を“編集中のファイル名"+数字13桁+".TMP"というファイル名で保存します。
  • 数字部分は、1970 年 1 月 1 日午前 00:00:00 以降のミリ秒です。
// saveAstemporary.js
// 2013-01-19

var s = Editor.ActiveDocument.Selection.Text;
if ( s.length == 0 ) { Quit() ;}
var filename = document.FullName;
Editor.NewFile();
var newdoc = Editor.Documents.Item( Editor.Documents.Count-1 );
newdoc.Write( s );
newdoc.save( filename + tail() );
newdoc.saved = true;
newdoc.close();

function tail() {
	d = new Date;
	return "." + d.getTime() + ".TMP";
}
スポンサーリンク