Comment detail

条件を満たす行を取り除く (Nested Flatten)
> cscript rem.js input.txt output.txt
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var objFSO = new ActiveXObject("Scripting.FileSystemObject");

function /* void */ rmComments( ifname, ofname ) {
    contents = "";
    if( objFSO.FileExists( ifname ) ) {
	ifileObj = objFSO.GetFile( ifname );
	streamR = ifileObj.OpenAsTextStream( 1 );
	streamW = objFSO.CreateTextFile( ofname );
	try {
	    while( !streamR.AtEndOfStream ) {
		contents = streamR.ReadLine();
		if( contents.search(/#/) != 0 ) {
		    streamW.WriteLine( contents );
		}
	    }
	} finally {
	    streamR.Close();
	    streamW.Close();
	}
    } else {
	throw (ifname + ": No Such File");
    }
    return;
}

var arg = WScript.Arguments.Unnamed;
rmComments( arg.Item(0), arg.Item(1) );

Index

Feed

Other

Link

Pathtraq

loading...