|
楼主 |
发表于 2009-8-11 15:25:02
|
显示全部楼层
afan,上次你教了我怎么设定一个限制去读取然后复制制定格式的文件,但是我对于那个Func_filelist看得不是很懂,所以在尝试往自己的程序里面添加的时候失败。
我的程序是还是那个创建文件夹和复制文件的程序,但是我尝试了,在func里面就不能够再加func来运行了,那么怎么把Func_filelist加进去呢?
$Form1 = GUICreate('Multi-Level Folder Creator', 387,265,-1,-1)
Dim $n = 1, $l[15], $s[15]
For $n = 1 To 14
$l[$n] = GUICtrlCreateLabel("Lv" & $n, 12 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 20 + 20 * (Int(($n - 1) / 5)), 30, 18)
$s[$n] = GUICtrlCreateInput("0", 45 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 17 + 20 * (Int(($n - 1) / 5)), 30, 16, $ES_NUMBER)
GUICtrlSetLimit(-1, 4)
Next
$yml = GUICtrlCreateInput("", 11, 85, 240, 23)
$Button = GUICtrlCreateButton("Create Folder / Copy File", 10, 160, 220, 25)
$Button1 = GUICtrlCreateButton("Remove All", 240, 160, 135, 25)
$Button2 = GUICtrlCreateButton("Source File Folder", 255, 84, 120, 26)
$Button3 = HotKeySet("{ESC}", "Terminate")
$gml = GUICtrlCreateInput("",11,120,240,23)
$Button5 = GUICtrlCreateButton("Target Folder", 255, 119, 120, 26)
$xs = GUICtrlCreateLabel("0/0 ", 175, 220, 300, 15)
GUICtrlSetColor(-1, 0xff0000)
$jdt = GUICtrlCreateProgress(10, 200, 365, 12,$PBS_SMOOTH)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
exit
Case $Button
GUICtrlSetData($jdt, 0)
GUICtrlSetState($Button, $GUI_ENABLE)
Dim $ywc = 0, $zs = 0, $sc = 1,$f,$h
jc()
AdlibEnable("jdt")
If GUICtrlRead($s[1]) = 0 then
msgbox(16, 'Error', 'Please set the number of folders')
Else
$f=MsgBox(1+48,'Attention','You will create ' & $zs & ' folders.' &@CRLF& 'Do you wish to continue?')
Select
Case $f=1
scml()
sleep(300)
AdlibDisable()
msgbox(64, 'Finish', 'Created ' & $zs & ' Folders! ')
Case $f=2
ContinueLoop
EndSelect
EndIf
GUICtrlSetState($Button,$GUI_ENABLE)
Case $Button1
$h=MsgBox(1+48,'Attention','Are you sure you want to Delete all the folders ?')
Select
Case $h=1
Del()
sleep(300)
msgbox(64, 'Finish', 'You have deleted all the folders! ')
Case $h=2
ContinueLoop
EndSelect
Case $Button2
$ywjj = FileSelectFolder("Choose The Folder", "", 4)
If @error Then ContinueLoop
GUICtrlSetData($yml, $ywjj)
Case $Button3
Terminate()
Case $Button5
$ywxx = FileSelectFolder("Choose The Folder", "", 4)
If @error Then ContinueLoop
GUICtrlSetData($gml, $ywxx)
EndSwitch
WEnd
Func Del()
Dim $num
For $num = 1 To 1000
$gmld = GUICtrlRead($gml)
DirRemove($gmld & '\' & 'MP3-'&$num,1)
Next
EndFunc
Func jc()
For $i = 14 To 1 Step -1
$sl = GUICtrlRead($s[$i])
If $sl > 0 then
For $i1 = 1 To $i
$sl1 = GUICtrlRead($s[$i1])
If $sl1 = 0 then
GUICtrlSetData($s[$i1], 1)
$sl1 = 1
endif
$zs = $zs + ($sc * $sl1)
$sc = $sc * $sl1
Next
ExitLoop
Endif
Next
EndFunc ;==>jc
Func Terminate()
Exit 0
EndFunc
Func scml()
$ymlr = GUICtrlRead($yml)
$gmlr = GUICtrlRead($gml)
$sl1 = GUICtrlRead($s[1])
If $gmlr = '' Then $gmlr = @ScriptDir
For $i1 = 1 To $sl1
$fn1 = 'MP3-'
$xml1 = $gmlr&'\'&$fn1&$i1
DirCreate($xml1)
$fh = FileOpen(@ScriptDir & "\1.txt", 1) ;从这里是复制文件的程序
_filelist($$ymlr, '.mp3')
FileClose($fh)
$fh = FileOpen(@ScriptDir & "\1.txt", 0)
While 1
$rl = FileReadLine($fh)
If @error = -1 Then ExitLoop
FileCopy($rl, $gmlr, 9)
WEnd
FileClose($fh)
FileDelete(@ScriptDir & "\1.txt") ; 到这里为止
$ywc = $ywc + 1
Next
Endfunc ;==>scml
Func jdt()
GUICtrlSetData($jdt, $ywc / $zs * 100)
GUICtrlSetData($xs, $ywc & '/' & $zs)
EndFunc ;==>jdt
这里我就弄了一层创建文件夹和复制文件,但是我就不明白在func scml()下面 又怎么可以添加你的Func_filelist进去呢??而且这个复制文件的命令又不能放在前面的while 1 loop里面。我感觉有点乱 |
|