Hey All,

I need to modify the length of this timer loop for this script i found
and need some feedback on if I am reading this timer loop correctly.

Do While intCounter < 3600
If objFso.FileExists(SEPExec) Then
logResults = logMessage("installSAV", "Installation of SEP
Completed")
intCounter = 3700
Else
Wscript.sleep 50
intCounter = intCounter + 1
end If
Loop

I need to basically know what is the max time in seconds this loop is
running before it goes on.
Is it 180 seconds?

If I wanted to increase it to 240 seconds can I just change the
wscript.sleep 50 to wscript.sleep 67?

Thanks for any assistance.

Clay

Re: Help with Timer loop by Richard

Richard
Wed Jul 09 19:09:28 CDT 2008


<cmatthews@lifelinecomputerservices.com> wrote in message
news:7ba5baec-5c79-4ce4-9b45-2683fd655bb7@d45g2000hsc.googlegroups.com...
> Hey All,
>
> I need to modify the length of this timer loop for this script i found
> and need some feedback on if I am reading this timer loop correctly.
>
> Do While intCounter < 3600
> If objFso.FileExists(SEPExec) Then
> logResults = logMessage("installSAV", "Installation of SEP
> Completed")
> intCounter = 3700
> Else
> Wscript.sleep 50
> intCounter = intCounter + 1
> end If
> Loop
>
> I need to basically know what is the max time in seconds this loop is
> running before it goes on.
> Is it 180 seconds?
>
> If I wanted to increase it to 240 seconds can I just change the
> wscript.sleep 50 to wscript.sleep 67?
>
> Thanks for any assistance.
>
> Clay

If intCounter starts at 0, and the If condition is never True, the code will
loop 3600 times with a 0.05 second pause per loop. This equates to 3600 x
0.05 = 180 seconds.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--



RE: Help with Timer loop by OldPedant

OldPedant
Wed Jul 09 19:13:00 CDT 2008


> I need to basically know what is the max time in seconds this loop is
> running before it goes on.
> Is it 180 seconds?

3600 * 50 is 180000 milliseconds which is of course 180 seconds.

Yes.

> If I wanted to increase it to 240 seconds can I just change the
> wscript.sleep 50 to wscript.sleep 67?

You could, but why not do it more sensibly, with simpler and easier to read
code??

CONST ALLOW_HOW_MANY_SECONDS = 240

EndAt = DateAdd( "s", ALLOW_HOW_MANY_SECONDS, Now( ) )
Do Until Now( ) >= EndAt
If objFso.FileExists(SEPExec) Then
logResults = logMessage("installSAV", "Installation of SEP
Completed")
Exit Do
End If
Wscript.sleep 50
Loop

Or, if you wanted to log either success or failure:

CONST ALLOW_HOW_MANY_SECONDS = 240

EndAt = DateAdd( "s", ALLOW_HOW_MANY_SECONDS, Now( ) )
result = "ERROR: Installation of SEP TIMED OUT!"
Do Until Now( ) >= EndAt
If objFso.FileExists(SEPExec) Then
result = "Installation of SEP Completed"
Exit Do
End If
Wscript.sleep 50
Loop
logResults = logMessage("installSAV", result )


Re: Help with Timer loop by Al

Al
Thu Jul 10 22:53:34 CDT 2008


"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
message news:OzkMDFi4IHA.4340@TK2MSFTNGP06.phx.gbl...
>
> <cmatthews@lifelinecomputerservices.com> wrote in message
> news:7ba5baec-5c79-4ce4-9b45-2683fd655bb7@d45g2000hsc.googlegroups.com...
>> Hey All,
>>
>> I need to modify the length of this timer loop for this script i found
>> and need some feedback on if I am reading this timer loop correctly.
>>
>> Do While intCounter < 3600
>> If objFso.FileExists(SEPExec) Then
>> logResults = logMessage("installSAV", "Installation of SEP
>> Completed")
>> intCounter = 3700
>> Else
>> Wscript.sleep 50
>> intCounter = intCounter + 1
>> end If
>> Loop
>>
>> I need to basically know what is the max time in seconds this loop is
>> running before it goes on.
>> Is it 180 seconds?
>>
>> If I wanted to increase it to 240 seconds can I just change the
>> wscript.sleep 50 to wscript.sleep 67?
>>
>> Thanks for any assistance.
>>
>> Clay
>
> If intCounter starts at 0, and the If condition is never True, the code
> will loop 3600 times with a 0.05 second pause per loop. This equates to
> 3600 x 0.05 = 180 seconds.

As written and taken out of context the answer is that it will loop any
number of times up to 3600 plus the largest negative number that could be
pre-assigned to the intCounter variable whose value would change by adding a
value of 1.

By my (admitedly very rough) calculation based on an initial value of
somewhere between -1E+15 and -1E+16, and assuming that the if condition
remains false (and you are still around to clock it with your stop watch) it
could continue to loop for at least 1585 - millenia. Buy a good UPS before
you try it...

/Al



Re: Help with Timer loop by Todd

Todd
Fri Jul 11 16:02:44 CDT 2008

Al Dunbar wrote:
> By my (admitedly very rough) calculation based on an initial value of
> somewhere between -1E+15 and -1E+16, and assuming that the if condition
> remains false (and you are still around to clock it with your stop watch)
it
> could continue to loop for at least 1585 - millenia. Buy a good UPS before
> you try it...

LOL. Microsoft AutoUpdate (or some other software) will no doubt force a
reboot sometime within the next month or two.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


Re: Help with Timer loop by Al

Al
Sat Jul 12 11:04:49 CDT 2008


"Todd Vargo" <tlvargo@sbcglobal.netz> wrote in message
news:OqHdLx54IHA.408@TK2MSFTNGP06.phx.gbl...
> Al Dunbar wrote:
>> By my (admitedly very rough) calculation based on an initial value of
>> somewhere between -1E+15 and -1E+16, and assuming that the if condition
>> remains false (and you are still around to clock it with your stop watch)
> it
>> could continue to loop for at least 1585 - millenia. Buy a good UPS
>> before
>> you try it...
>
> LOL. Microsoft AutoUpdate (or some other software) will no doubt force a
> reboot sometime within the next month or two.
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)

It just occurred to me that the loop would effectively become infinite
rather than being limited to under two thousand millenia. If the initial
value of the counter were greater in magnitude than about -1E+16, then
adding one to it will leave it unchanged. Silly me to leave out this
simplifying detail...

/Al