In that case put the timing loop INSIDE dothisfunction() and rather than
breaking out of the loop, execute a return to the calling script.

Ignatius Teo
Project Manager, Internet Access Services
Information Technology Directorate
Southern Cross University
PO Box 157, Lismore NSW 2480
Email: iteo_at_scu_edu_au
Phone: +61 2 6620-3221
Fax  : +61 2 6620-3033
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GB/IT$ d++(-)@ s++:++@ a>? C++++ UL !P$ L+
!E W+$ N- o? !K w O---- M- V PS PE++ Y+(--)
PGP- t++@ 5-- X++@ R* tv- b+ DI++ D++@ G
e++ h---- r+++ y++++**
------END GEEK CODE BLOCK------




-----Original Message-----
From: Brendan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 23 May 2001 09:55
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] RE:escape loop on timeout




Zak Greant wrote:

> Johan Lundqvist wrote:
> > This is a way of doing it:
> >
> > $s = time() + 10;
> > for ($i = time(); $i <= $s; $i++) {
> >     print $i;
> > }
> >
> > Will run for about ten seconds...
>
>     Did you leave a bit of code out?
>     In most cases, this will run for only a few milliseconds. :)
>
>     Try something like this instead:
>
>     $timeout = 1;            // Timeout in seconds
>     $start_time = time();    // Get the current time
>
>     for ($x=0; $x < 1000000000; ++$x) {
>
>         /*
>         // Check if we have gone over the time limit
>         // Only check every 1000 loops - this keeps
>         // us from chewing run time by checking the time
>         // all the time :)
>         */
>         if ( (0 === ($x % 1000)) && (time () - $start_time) > $timeout)
>             break;
>
>         echo ($x, '<br>');
>     }
>
>     --zak
>

----------------

Thanks guys

sorry about the delay .. I am in Australia..
checking the time each loop would only work if the loops complete correctly
.. if the process locks mid loop php wont reach the criterion break because
it deals with each command linearly. ie

for (x=0;x!="array full";x++)
 dothisfunction(x);
    if ( (0 === ($x % 1000)) && (time () - $start_time) > $timeout)
            break;
etc

if dothisfunction() locks up wont the entire script freeze?

maybe I am wrong..

what I am after is something like alert() in Perl or the 'on error resume
next' in ASP which runs externally to the loop and breaks to the next
instance if it is taking too long...
any ideas?
cheers!








--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to