Js read configuration file to write from
- 2020-03-30 01:41:06
- OfStack
Write their own with js to read the configuration file procedures
D: \ Useful Stuff \ Javascript \ mytest TXT
The file contents are as follows
[plugin_page_search]
wholeword=0
matchcase=1
hightlight=1
total=1
[data]
up=85
down=5
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile("D:\Useful Stuff\Javascript\mytest.txt",1);
var s = "";
while (!f.AtEndOfStream)
{
s+= f.ReadLine();
}
f.Close();
function getINI(item,key)
{
new RegExp("\["+item+"\](.+)").exec(s);
var str=RegExp.$1;
var reg2=/(w+)=(d+)/;
var keyValue={};
str.replace(reg2,function(a,b,c){
keyValue[b]=c;
});
return keyValue[key];
}
alert(getINI("data","up"));
alert(getINI("plugin_page_search","hightlight"));