quicksilver Posted August 25, 2005 Posted August 25, 2005 (edited) Hello i've got written a little program thats look into a folder an Prints all the txt files with a specified program. But now my problem.. when the folder is empty the program quits with this message: But i want that the program runs endless until it will be closed in the trayand here the program:expandcollapse popupWhile "0"="0" $ini_file = "dirlist.ini" $file = FileOpen($ini_file, 0) ; Variablen einlesen $program = FileReadLine($file,1) $workdir = FileReadLine($file,2) $sicherung = FileReadLine($file,3) $filenames = FileReadLine($file,4) $sleepzeit = FileReadLine($file,8) FileClose($file) $search = FileFindFirstFile($filenames) ; Check if the search was successful If $search = -1 Then ;MsgBox(0, "Error", "No files/directories matched the search pattern") ;Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $execute = $program&" "&$workdir&$file $source = $workdir&$file $dest = $sicherung&$file RunWait($execute,$workdir) FileMove($source, $dest) ; --- logfile $files = FileOpen($ini_file, 0) ; Variablen einlesen $pretext = FileReadLine($files,5) $logfile = FileReadLine($files,6) $aftertext = FileReadLine($files,7) FileClose($files) $Input_Date = @MDAY & "-" & @MON & "-" & @YEAR $Input_Time = @HOUR & ":" & @MIN & ":" & @SEC $thetime = "Datum und Uhrzeit: "&$Input_Date&" - "&$Input_Time&" - "&$file $Input_Date_File = @MDAY & "_" & @MON & "_" & @YEAR $Input_Time_File = @HOUR & "_" & @MIN $logfilename = $logfile&"log__"&$Input_Date_File&"__"&$Input_Time_File&".txt" ; Logfile Erstellen $files = FileOpen($logfilename, 1) FileWriteLine($files, $pretext) FileWriteLine($files, $thetime) FileWriteLine($files, $aftertext) FileClose($files); ; --- logfile WEnd ; Close the search handle FileClose($search) ; -------------------------------- $sleepzeit = $sleepzeit*60000 Sleep($sleepzeit) WEnd Exitthx for help Edited August 25, 2005 by quicksilver
Raindancer Posted August 25, 2005 Posted August 25, 2005 (edited) when the folder is empty the program quits with this message: <{POST_SNAPBACK}>When you run it as Script (Eg. in SciTe) then it shows you at which line the Error occured. If it is compiled then it only shows Line 0.Try it again. Maybe you'll find your error.Edit: Ich kann dir sonst auch auf Deutsch helfen wenn es für dich einfacher ist Edited August 25, 2005 by Raindancer Say: "Chuchichäschtli"My UDFs:_PrintImage UDF_WinAnimate UDFGruess Raindancer
quicksilver Posted August 25, 2005 Author Posted August 25, 2005 (edited) there is no error in the script. The script returns that the path where the files are is empty. After this it quits.. is there any way to stop this? Edit: Jo Also das script gibt nur zurück das der pfad leer ist.. ansonsten geht es ja. wenn dateien im verzeichnis liegen funzt es 1a aber wenn der pfad leer ist beendet sich das programm. Ich müsste einfach die fehlermeldung unterdrücken. Geht das irgendwie? Edited August 25, 2005 by quicksilver
/dev/null Posted August 25, 2005 Posted August 25, 2005 (edited) $search = FileFindFirstFile($filenames) ; Check if the search was successful If $search = -1 Then ;MsgBox(0, "Error", "No files/directories matched the search pattern") ;Exit EndIfFileFindFirstFile returns -1 when it detects an error (e.g. no files found). You cannot use -1 as a search handle! There is already some code to test that error condition, however, you'll have to do something meaningful.If $search = -1 Then sleep(10000) continueloop;-- The outer while loop !! EndIfBTW: Is it really necessary to read the INI file within the while loops? Could be done outside of the loops.CheersKurt Edited August 25, 2005 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Raindancer Posted August 25, 2005 Posted August 25, 2005 (edited) This should work: expandcollapse popupWhile "0"="0" $ini_file = "dirlist.ini" $file = FileOpen($ini_file, 0) ; Variablen einlesen $program = FileReadLine($file,1) $workdir = FileReadLine($file,2) $sicherung = FileReadLine($file,3) $filenames = FileReadLine($file,4) $sleepzeit = FileReadLine($file,8) FileClose($file) ;$program = "EDI2TXT.EXE" ;$workdir = "C:\Temp\schaefer\import\" ;$sicherung = "C:\Temp\schaefer\save\" ;$filenames = "C:\Temp\schaefer\import\data_*.txt" $search = FileFindFirstFile($filenames) ; Check if the search was successful If Not $search = -1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $execute = $program&" "&$workdir&$file $source = $workdir&$file $dest = $sicherung&$file RunWait($execute,$workdir) FileMove($source, $dest) ; --- logfile $files = FileOpen($ini_file, 0) ; Variablen einlesen $pretext = FileReadLine($files,5) $logfile = FileReadLine($files,6) $aftertext = FileReadLine($files,7) FileClose($files) $Input_Date = @MDAY & "-" & @MON & "-" & @YEAR $Input_Time = @HOUR & ":" & @MIN & ":" & @SEC $thetime = "Datum und Uhrzeit: "&$Input_Date&" - "&$Input_Time&" - "&$file $Input_Date_File = @MDAY & "_" & @MON & "_" & @YEAR $Input_Time_File = @HOUR & "_" & @MIN $logfilename = $logfile&"log__"&$Input_Date_File&"__"&$Input_Time_File&".txt" ; Logfile Erstellen $files = FileOpen($logfilename, 1) FileWriteLine($files, $pretext) FileWriteLine($files, $thetime) FileWriteLine($files, $aftertext) FileClose($files); ; --- logfile WEnd EndIf ; Close the search handle FileClose($search) ; -------------------------------- $sleepzeit = $sleepzeit*60000 Sleep($sleepzeit) WEnd Exit It only runs the inner loop if the folder isn't empty. Edit: /dev/nulls lösung ist die hübschere von beiden ;-) Edited August 25, 2005 by Raindancer Say: "Chuchichäschtli"My UDFs:_PrintImage UDF_WinAnimate UDFGruess Raindancer
quicksilver Posted August 25, 2005 Author Posted August 25, 2005 Thx no it works:) nice job Danke euch
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now