Sign in to follow this  
Followers 0
Queener

A loop delete

6 posts in this topic

#1 ·  Posted (edited)

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



#3 ·  Posted (edited)

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

#4 ·  Posted (edited)

czardas,

In While...Wend can be used an expression instead of 1 or other numeric value, like:

While ProcessExists($Process)
;etc.
While $var = 1
;etc.
While @MIN <> 42
;etc
Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

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.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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  
Followers 0