源碼運行約2天時間,會出"迴圈層數已超過範圍"
#include <Constants.au3>Dim $i
$ADSL =IniRead("C:\ADSL.ini", "ADSL", "LAN", "")
$us =IniRead("C:\ADSL.ini", "ADSL", "USERNAME", "")
$ps =IniRead("C:\ADSL.ini", "ADSL", "PASSWD", "")
a()
Func a()
Sleep(1000)
$foo = Run(@ComSpec & " /c ipconfig", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(500)
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
$i = $line
Sleep(200)
WEnd
If StringInStr ($i,"PPP adapter ADSL:") = 0 Then
b()
Else
Sleep(29000)
a()
EndIf
EndFunc
func b()
if FileExists("c:\adslup.txt") Then
$file = FileOpen("c:\adslerr.txt",1)
$time = @year& "-"&@mon &"-"&@MDAY&"-"& @hour & ":" & @MIN &":" & @SEC
FileWrite($file,"斷線時間:"& $time&@CRLF)
FileClose($file)
Else
$file1 = FileOpen("c:\adslup.txt",1)
FileClose($file1)
EndIf
runWait("C:\WINDOWS\system32\rasdial.exe"&" "&$ADSL&" "&$us&" "&$ps ,"C:\WINDOWS\system32\")
Sleep(5000)
a()
EndFunc
{:face (131):}迴这个是什么字 回复 2# amxi
迴圈就是loop 当然会出现递归错误,函数间的嵌套调用都没有返回。你把Sleep注释掉 或把时间改小一点,这段代码将会在几分钟之内就出现这个错误。 回复 4# pusofalse While 1
if a() = 0 Then
b()
Else
Sleep(29000)
EndIf
WEnd
Func a()
Sleep(1000)
$foo = Run(@ComSpec & " /c ipconfig", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(500)
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
$i = $line
Sleep(500)
WEnd
If StringInStr ($i,"PPP adapter ADSL:") = 0 Then
Return 0
Else
Return 1
EndIf
EndFunc
func b()
if FileExists("c:\adslup.txt") Then
$file = FileOpen("C:\adslerr.txt",1)
$time = @year& "-"&@mon &"-"&@MDAY&"-"& @hour & ":" & @MIN &":" & @SEC
FileWrite($file,"斷線時間:"& $time&@CRLF)
FileClose($file)
Else
$file1 = FileOpen("c:\adslup.txt",1)
FileClose($file1)
EndIf
runWait("C:\WINDOWS\system32\rasdial.exe"&" "&$ADSL&" "&$us&" "&$ps ,"C:\WINDOWS\system32\")
EndFunc
感謝大大回覆
我已修改 递归没出来,A里面又套了A
页:
[1]