关于VBS的好软件一直找不到,写长一点的脚本很不美观
次碳酸钴童鞋叫我用记事本弄缩进,汗颜
于是就用记事本写了这个,本来以为 so easy
可惜浪费我整整三天光**ut收益匪浅。
‘==============================================================================
set wshell=createobject("wscript.shell")
Set fso=CreateObject("Scripting.FileSystemObject")
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "VBE Files|*.vbe|VBS File|*.vbs|all files|*.*"
objDialog.InitialDir = ""
for g=1 to 3
objDialog.ShowOpen
File = objDialog.FileName
if File<>"" then exit for
wrong
next
dim a(10000)
k=3
Set w=fso.OpentextFile(File,1)
do
s=w.readline
DC s
r=num(s)
if r<0 then k=r+k
for z= 1 to k
s=" "&s
next
if r>0 then k=r+k
n=n+1
a(n)=s
if n>9999 then wrong
loop until w.atendofstream
Set w=fso.OpentextFile(File,2)
for q=1 to n
w.writeline a(q)
next
sub wrong
u=wshell.popup("非法文件!"&chr(13)&chr(13)&"是否继续?",9,"wrong!",20)
if u=7 then wscript.quit
end sub
sub DC(byref s)
for e=1 to len(s)
if mid(s,e,1)<>" "then exit for
next
s=mid (s,e)
end sub
function num(ss)
num=0
dim f
f=split(ss," ",-1,1)
for each x in f
if x<>" "then
x=ucase(x)
IF x="DO" OR x="FOR" OR X="SUB" OR X="FUNCTION" OR X="WHILE" OR X="WITH" OR x="SELECT" THEN num=3
if x="IF" then num=conif(f)
if x="END" or x="NEXT" or x="WEND" or x="LOOP" then num= -3
exit function
end if
next
end function
function conif(f)
for each b in f
o=o+1
if ucase(b)="THEN" then
if UBound(f)>o+1 then
if f(o+1)<>" " then conif=0:exit function
end if
end if
next
end function
关于单行的 IF 处理还是不到位,conif函数就是为了解决这个,还是没解决好
许多字符处理函数还不会运用,完全是靠着03年的老手册来的,事实上还可以在简便点.
在循环中能如何使用读一句处理完就写入的方法?节约内存