- @set @n=0/*&echo off
- ::源文件路径
- set "SrcTxt=%~dp0test.txt"
- if not exist "%SrcTxt%" echo;file not found&pause&exit
-
- for /f "tokens=1,2" %%a in ('cscript -nologo -e:jscript "%~0" "%SrcTxt%"') do set "a=%%a"&set "b=%%b"
- echo;a=%a%
- echo;b=%b%
- pause&exit */
-
-
- //以下是JS代码
- var fso=new ActiveXObject('scripting.FileSystemObject');
- fo =fso.OpenTextFile(WScript.Arguments(0));
- var count=0;
- while(!fo.AtEndOfStream)
- {
- line=fo.ReadLine();
- if(line.match(/ROTOT|ROTORMASS/gim))
- while(!fo.AtEndOfStream)
- {
- line=fo.ReadLine();
- count+=1;
- switch(count)
- {
- case 1:
- num=line.replace(/.*\s+([0-9.]+)\s+[0-9.]+$/gim,'$1');
- a=(4*6500*num/1500).toFixed(4);
- break;
- case 4:
- num=line.replace(/.*\s+([0-9.]+)\s+[0-9.]+$/gim,'$1');
- b=(4*6500*num/1500).toFixed(4);
- break;
- }
- if(4==count) break;
- }
- if(4==count) break;
- }
- WSH.Echo(a,b);
- fo.close();
复制代码
|