473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

while loop closure

hi all

in my js code i have a while loop contained within a while loop
executed on the basis of a conditional if statement, what i want to do
is end the entire function on the last execution on the 2nd while loop
(contained within the 1st), bcos the 2nd while loop changes the
condition evaluated by the if statement which means another while loop
(executed where if evaluates differently) gets executed straight
afterwards

can anyone help me on this?

regards

marc

Aug 28 '06 #1
3 1821
"libsfan01" <mc******@googlemail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
hi all

in my js code i have a while loop contained within a while loop
executed on the basis of a conditional if statement, what i want to do
is end the entire function on the last execution on the 2nd while loop
(contained within the 1st), bcos the 2nd while loop changes the
condition evaluated by the if statement which means another while loop
(executed where if evaluates differently) gets executed straight
afterwards

can anyone help me on this?
You could place both "while" constructs in a function then
"return" (exit) from the function based on your criteria.
Aug 28 '06 #2
http://www.devguru.com/Technologies/...ript/11471.asp

"libsfan01" <mc******@googlemail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
hi all

in my js code i have a while loop contained within a while loop
executed on the basis of a conditional if statement, what i want to do
is end the entire function on the last execution on the 2nd while loop
(contained within the 1st), bcos the 2nd while loop changes the
condition evaluated by the if statement which means another while loop
(executed where if evaluates differently) gets executed straight
afterwards

can anyone help me on this?

regards

marc
Marc
you can use break followed by a label name to break out of either or both
loops.
its described here:
http://www.devguru.com/Technologies/...ript/11471.asp

HTH
Aug 29 '06 #3
libsfan01 wrote:
hi all

in my js code i have a while loop contained within a while loop
executed on the basis of a conditional if statement, what i want to do
is end the entire function on the last execution on the 2nd while loop
(contained within the 1st), bcos the 2nd while loop changes the
condition evaluated by the if statement which means another while loop
(executed where if evaluates differently) gets executed straight
afterwards

can anyone help me on this?
Simply return when the condition is true:

function foo(){
while ( ... ){
if ( ... ){
while ( ... ){
if ( ... ) return ... ;
}
}
}
return ... ;
}
--
Rob

Aug 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Ted Lilley | last post by:
What I want to do is pre-load functions with arguments by iterating through a list like so: >>>class myclass: .... pass >>>def func(self, arg): .... print arg >>>mylist = >>>for item...
1
by: Victor Ng | last post by:
Is there a way to preserve the argspec of a function after wrapping it in a closure? I'm looking for a general way to say "wrap function F in a closure", such that inspect.getargspec on the...
9
by: Mikito Harakiri | last post by:
Transitive closure (TC) of a graph is with TransClosedEdges (tail, head) as ( select tail, head from Edges union all select e.tail, ee.head from Edges e, TransClosedEdges ee where e.head =...
10
by: Sean Dockery | last post by:
I have the following HTML file that I've been using for testing... <html> <head> <script type="text/javascript"> <!-- function handleWindowLoad() { var items = ; for (var i = 0; i < 11; i++)...
7
by: Csaba Gabor | last post by:
I feel like it's the twilight zone here as several seemingly trivial questions are bugging me. The first of the following three lines is a syntax error, while the last one is the only one that...
9
by: User1014 | last post by:
I'm a javascript noob and have a question concerning some code I've come across that I'm trying to understand. Here is a snippet of the relevant section: (snip) var closure = this; var xhr =...
0
by: Gerard Brunick | last post by:
Consider: ### Function closure example def outer(s): .... def inner(): .... print s .... return inner .... 5
11
by: Huayang Xia | last post by:
What will the following piece of code print? (10 or 15) def testClosure(maxIndex) : def closureTest(): return maxIndex maxIndex += 5 return closureTest()
1
by: joe_doufu | last post by:
I'm creating a page with multiple "widgets", each with its own XMLHttpRequest object, so the user can play with the widgets in parallel. The widgets are enclosed in divs with class "widget" and a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.