Forum Moderators: open

Message Too Old, No Replies

Limit number of requests using a timer function

         

macrost

4:35 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



I have some code, but the problem is this:
When the page loads, the Timer() function starts, regardless if I have it in an If statement. I'm trying to limit the loop by a time difference.

Here's a brief snippit of code.


If Request.Form("submit1") = "Submit" Then
For i = 1 To Session("times")
StartTime = Timer()
'do processing stuff here
foobar = 1 * 9
If Timer() - StartTime >= 20 Then
Next
End If

But on page load, then the obvious error is thrown.
Unexpected 'Next'

Any ideas or thoughts?

mattglet

4:50 pm on Apr 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try:

do while session("times") < 20

loop

-Matt

macrost

5:25 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



Ok, after some searching, I have found a free component that does this for you.

Try this search:
[google.com...]

[edited by: Xoc at 9:48 am (utc) on April 9, 2004]
[edit reason] activated link [/edit]

Xoc

9:51 am on Apr 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



actually, all you need is:

dim starttime

starttime = Now()
do until Now()-starttime >= #0:00:20#
'do stuff
loop