Sign in to follow this  
Followers 0
Doxie

Simple question regarding loop.

5 posts in this topic

This is not working, complains about overflow... :ph34r:

First()
Second()
Exit

Func First()
Run("net use z: \\server\share /user:**** ***** /y")
EndFunc

Func Second()
$var = DriveStatus( "z:\" )
IF $var = "READY" THEN
    FileCopy("z:\test2.txt", "C:\")
    Run("net use z: /d")
Else
    Second()
EndIf
Sleep(5000)
EndFunc
Exit

How can i make it continue testing the DriveStatus and proceed when ready?

I could use a simple "Sleep" command, but since the time it take to map the drive vary alot, it would be best if it could just check when its done.

Any suggestions?


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites



How can i make it continue testing the DriveStatus and proceed when ready?

Try this:

First()
Second()
Exit

Func First()
  Run("net use z: \\server\share /user:**** ***** /y")
EndFunc

Func Second()
  While DriveStatus("z\") <> "READY"
    Sleep(100)
  WEnd
  FileCopy("z:\test2.txt", "C:\")
  Run("net use z: /d")
  Sleep(5000)
EndFunc
Exit

Note how I don't use a recursive function call when it could theoretically call up to the max allowed recursion level. Use a while loop instead for that.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

This seems to work :ph34r:

Else
    Sleep(5000)
    Config()
EndIf
EndFunc

I just moved the sleep command, and now it does not complain about overflow.


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites

Thanks Pekster

I need to learn more about the while loops :ph34r:

Your code look much better then my desperate attempt.

:iamstupid:


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites

I remade the whole script, now it looks like this.

Run("net use z: \\server\share /user:***** ***** /y")

 While DriveStatus("z:\") <> "READY"
   Sleep(100)
 WEnd
 FileCopy("z:\*.*", "d:\")
Run("net use z: /d")
Sleep(5000)
Exit

Less code, but doing the job better :ph34r:

PS. I really like to use the smilies :(


Were ever i lay my script is my home...

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