Jump to content
Sign in to follow this  
Queener

A loop delete

Recommended Posts

This codes work, but was wondering if there's any better way to write it shorter or (a better code)? Second question is - is it possible to have it check .log on sub folders on desktop as well?

$filetype = @DesktopDir & "\*.log"

Deleteit()

Func Deleteit()
if FileExists($filetype) Then
    FileDelete($filetype)
    Gowait()
Else
    Gowait()
EndIf
EndFunc

Func Gowait()
    sleep(60000)
    Deleteit()
EndFunc
Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites

AdlibRegister("Deleteit", 60000)
While Sleep(1000)
Wend

Func Deleteit()
if FileExists($filetype) Then
    FileDelete($filetype)
EndIf
EndFunc

Edited by JohnOne

Share this post


Link to post
Share on other sites

JohnOne - where did you get that from?

While Sleep(1000)

I know why it works, but I never saw anyone use it before. It reads a little odd. I would have written:

;

While 1
    Sleep(1000)
Wend

;

@asianqueen >This UDF might be useful to you.

Edited by czardas

Share this post


Link to post
Share on other sites

JohnOne - where did you get that from?

While Sleep(1000)

I know why it works, but I never saw anyone use it before. It reads a little odd. I would have written:

;

While 1
    Sleep(1000)
Wend

;

@asianqueen >This UDF might be useful to you.

I don't know to be honest, I think it equates to 1, but I imagine if Sleep() fails for some reason, the loop will exit, so probably not recommended really.

Share this post


Link to post
Share on other sites

I don't know to be honest, I think it equates to 1, but I imagine if Sleep() fails for some reason, the loop will exit, so probably not recommended really.

 

Cool idea, but I think it's a bit confusing for a beginner. Of course anything non-zero (or boolean True) should work.

Edited by czardas

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...