In comp.lang.javas cript message <1b2203dtih5ts0 l99m94fin52ra92 gskqg@4ax.
com>, Wed, 21 Mar 2007 10:44:40, Cogito <no****@nospam. nospamposted:
>
As they say, back to the drawing board. I think that my two nested
'for' loops will have to go and be replaced by a single 'while' loop.
It seems that since I modify the values of 'col' and 'row' in the loop
itself, I somehow end up in an endless loop.
One can do that in javascript, but it is generally better not to alter
the control values for FOR loops in the body of the loop.
>One more question before I embark on reshaping the code: Can you have
multiple conditions to control the termination of a loop ('for' or '
while') or is it limited just one condition? Searching through some of
the sites I could not find an example with more than one test.
There can only be a single Boolean condition; but the calculation of
that can be as complex as you like.
This peculiar sample code, if executed in alternate 5-second periods on
a Wednesday, will whizz-count in status until the end of the period, and
otherwise does nothing :-
for ( ; D = new Date(), D.getSeconds()% 10<5 && D.getDay()==3 ; )
{ window.status++ }
A break statement will also terminate a loop; and the condition for
its execution is a Boolean value, calculated however you wish; so the
contents of if( ) can be a complex Boolean expression.
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
news:comp.lang. javascript FAQ <URL:http://www.jibbering.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.