以下妄想紙芝居。
機械的なワークフローって重要だなあ、とつくづく思う。Eメールが飛んでいるが状態が把握できねかねるというか、メッセージ同士が関連づいてないので無理。Outlookの「並べ替え→テーマ」は使えなさすぎ。RFCとかインターネットの慣習ってやっぱ結構まともだよね。コンプライアンスのせいで内部レビュー→実際にメール送信とかになってるのをメールでやるせいでさらにこれはひどい的雰囲気。Eメールはそんな分岐には対応してないわけで。あとプレーンテキストってシリアルデータなんだなーと思った。「-----ここから-----」「-----ここまで-----」とか何度も出てくるのは生理的に無理。まあMicrosoft的にはSharePoint買えっていう話のような気もするけど。MAPIだからインターネットメールとは非互換ですとか何年言ってるんだよ的な?特技=仕様変更ってみんな思ってるんだし、早めに手を打っておけば今頃なんとかなってたんじゃないの的な。
WindowsXPで英語配列を使えるようにレジストリを書き換えて、そこでVMWareを起動してその中のWindowsで_を入力すると=になってガッカリした(スキャンコードをそのまま送ってるらしい)ので、左Ctrlに109日本語キーボードの「\_」を割り当ててやった。特に反省はしていないが、\の入力がすごく辛くてびっくり。
クリップボードは、一度だけダイアログが出るけどIE経由でアクセス可能らしい。(以下エスケープ抜けてたらごめんなさい)
function Clipboard() {
throw new Error('Clipboard: new 演算子を使用は禁止されています');
}
(function () {
var $ = Clipboard.prototype;
//window is initialized in fake-ie.js
//var window;
$.initialize = function () {
//var e = new ActiveXObject('InternetExplorer.Application');
//e.navigate('about:blank');
//while (e.busy || e.readyState !=4)
// WScript.sleep(100);
//window = e.document.parentWindow;
return this;
}
$.clear = function () {
window.clipboardData.clearData();
}
$.get = function () {
return window.clipboardData.getData('TEXT');
}
$.set = function (anObject) {
return window.clipboardData.setData('TEXT', anObject.toString());
}
// Note that the object reference e.document.parentWindow.clibboardData changes each time
// the value of the clipboard changes. Assume the local variable c where the reference
// e.document.parentWindow.clibboardData is bound. $.get (closure) closes the binding
// for c and always returns the value of the clipboard at which the $get is created.
// Hence $.get has to refresh the reference each time an access is needed. (2004/09/23)
})();
(function () {
var $ = Clipboard;
// $.defaultClipboard = function () { // <- its verbose
$.get = function () {
var proto = Clipboard.prototype;
if (proto.DefaultClipboard)
return proto.DefaultClipboard;
else {
var TemporaryConstructor = new Function();
TemporaryConstructor.prototype = Clipboard.prototype;
var clipboardObject = new TemporaryConstructor();
clipboardObject.initialize();
proto.DefaultClipboard = clipboardObject;
return clipboardObject;
}
}
})();あとIOが使いづらい(APIはあるが生理的に無理)ので、RubyのFileを真似しようと中途半端にでっち上げたり
/*
*
*
*/
var Dir = function() {
this.initialize.apply(this, arguments);
}
Dir.prototype = {
name: null,
dir: null,
initialize: function(name) {
this.name = name;
this.open();
},
open: function(){
this.dir = File.fso().GetFolder(this.name);
},
close: function(){
this.dir.close();
},
reopen:function(){
this.close();
this.open();
},
each: function(itr){
(new Enumerator(this.dir.Files)).each(itr);
}
}
Dir.glob = function(dir, re, itr) {
var e = new Enumerator(File.fso().GetFolder(dir).Files);
e.each(function(f) {
if (re.test(f.Name)) {
itr(f);
}
});
}
var File = function() {
this.initialize.apply(this, arguments);
}
File.prototype = {
imode: 1,
stream: null,
name: '',
fso: null,
initialize: function(name, mode) {
this.name = name;
this.fso = WScript.CreateObject('Scripting.FileSystemObject');
if (/\+/.test(mode)) {
this.imode = 8;
} else if (/r/.test(mode) && /w/.test(mode)) {
this.imode = 0;
} else if (/w/.test(mode)) {
this.imode = 2;
}
this.open();
var a = $A(arguments);
if (typeof a.last() == 'function') {
try {
(a.last())(this);
} catch (ex) {
throw(ex);
} finally {
this.close();
}
}
},
open: function() {
var s;
if (this.imode != 1 && !this.fso.FileExists(this.name)) {
s = this.fso.CreateTextFile(this.name, false);
} else {
s = this.fso.OpenTextFile(this.name, this.imode);
}
this.stream = s;
},
print: function(str) {
return this.stream.Write(str);
},
puts: function(str) {
return this.stream.WriteLine(str);
},
read: function(i) {
return this.stream.Read(i);
},
gets: function() {
return this.stream.ReadLine();
},
each_line: function(fn) {
while (!this.stream.AtEndOfStream) {
fn(this.gets());
}
this.reopen();
},
close: function() {
return this.stream.Close();
},
reopen: function() {
this.close();
this.open();
}
};
File.fso = function(fn) {
var x = WScript.CreateObject('Scripting.FileSystemObject');
//File.fso = function(){return x};
return x;
}
File.atime = function(fn) {
return this.fso().GetFile(fn).DateLastAccessed;
}
File.basename = function(fn) {
return this.fso().GetFileName(fn);
}
File.ctime = function(fn) {
return this.fso().GetFile(fn).DateCreated;
}
File.unlink = function(fn) { //delete is statement
return this.fso().DeleteFile(fn);
}
File.dirname = function(fn) {
return this.fso().GetParentFolderName(fn);
}
File.extname = function(fn) {
return this.fso().GetExtensionName(fn);
}
File.mtime = function(fn) {
return this.fso().GetFile(fn).DateLastModified;
}
File.rename = function(from, to) {
return this.fso().MoveFile(from, to);
}
File.expand_path = function(path) {
return this.fso().GetAbsolutePathName(path);
}
new File('hoge/fuga.txt', 'r', function(fd){var i = 0;fd.each_line(function(l){print((++i) + '. ' + l)})})とかできる(ファイル読んで番号付けて出力の意)。しかしJavaScriptはfunctionとClassの関係とかprototypeまわりとか全然理解できないな。
追記。eachを一度実行してしまうと再利用できなかったバグを修正した記憶があるので差し替え。Dirのほうはなんかよろしくない。インタラクティブ環境はdata-jさんのやつのほうが、複数行編集できるようになってるので嬉しいかもしれず。