Continue if file found
Continue if file found
Can anyone help me with a basic function, find a file and if it dont exist repeat find until it does then continue?
Why would it help to keep looking for a file that doesn't exist?abc123 wrote:Can anyone help me with a basic function, find a file and if it dont exist repeat find until it does then continue?
@EDIT: My answer was supposed to include some code but byo beat me to it, including coding the delay to prevent the infinite loop. The Submit button is a little too close to the Preview button sometimes. )
Last edited by Demivec on Mon Oct 15, 2007 8:39 pm, edited 1 time in total.
I'd use this:
But you have to make sure the file is being created or you'll be stuck in the loop. I'm not sure how much CPU it'll use but that Delay can help you.
hmm... I'm sure it's bad programming.
You could use:
if you don't need to check the file's integrity. I'm pretty sure it's bad programming as well as you may get stuck with no error catching.
.
Code: Select all
Repeat
Delay(10)
Until FileSize(file.s) >= fileSize.l
hmm... I'm sure it's bad programming.
You could use:
Code: Select all
Repeat
Delay(10)
Until FileSize(file.s) > -1
.
I have exe that reads of a file created with that exe, so sometimes it shows up with nothing cause the file hasnt been created.Demivec wrote:Why would it help to keep looking for a file that doesn't exist?abc123 wrote:Can anyone help me with a basic function, find a file and if it dont exist repeat find until it does then continue?
you can also use a flag in you mainloop (if you have one)
and just leave out actions according to the existence of that file.
and just leave out actions according to the existence of that file.
Code: Select all
Repeat
fileExists = (0 Or (FileSize(filenames$) >= 0))
;do general stuff
;do general stuff
If FileExists
;do special stuff
;do special stuff
Else
;do other stuff
;do other stuff
EndIf
;do general stuff
;do general stuff
If thisOrThat
quit=1
EndIf
Delay(20)
Until quit
But if the application doesn't create the file in the first place, why make a loop to continually check for a file that won't ever be there?abc123 wrote:I have exe that reads of a file created with that exe, so sometimes it shows up with nothing cause the file hasnt been created.Demivec wrote:Why would it help to keep looking for a file that doesn't exist?abc123 wrote:Can anyone help me with a basic function, find a file and if it dont exist repeat find until it does then continue?