473,770 Members | 4,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I miss loop

cj
When I'm inside a do while loop sometimes it's necessary to jump out of
the loop using exit do. I'm also used to being able to jump back and
begin the loop again. Not sure which language my memories are of but I
think I just said loop somewhere inside the loop and it immediately
jumped back to the start of the loop and began again. I can't seem to
do that in .net. I this functionality available?
Mar 14 '06
32 2606
cj
Yes, that'll also work.

Sebastian wrote:
I think you may have misunderstood the suggestion for using goto. Make
the goto go to the end of the loop, not the beginning, and you get
exactly the functionality of a continue statement, no messy inner loop.

Ex:
do
.
if something goto LoopContinue
.
.
.
if something goto LoopContinue
.
if something goto LoopContinue
.

LoopContinue:
while continue
cj wrote:
I thought about that this AM but after all the thought I have a double
do loop.

do
do
.
if something exit do
.
.
.
if something exit do
.
if something exit do
.
while innerLoop
while continue

Not beautiful but it was time to make a decision and move on.
Couldn't bring myself to use goto.

Scott M. wrote:
How about making the loop in its own procedure that can take the
appropriate arguments you'll need to use to determine if the loop "is
going well and should continue"?

You can still exit from the loop (or from the sub if the loop is in
one) if you need to and you'd be able to re-call the loop/procedure
and pass it what it needs to begin again.

"cj" <cj@nospam.nosp am> wrote in message
news:ex******** ******@tk2msftn gp13.phx.gbl...
When I'm inside a do while loop sometimes it's necessary to jump out
of the loop using exit do. I'm also used to being able to jump back
and begin the loop again. Not sure which language my memories are
of but I think I just said loop somewhere inside the loop and it
immediately jumped back to the start of the loop and began again. I
can't seem to do that in .net. I this functionality available?

Mar 16 '06 #31
cj <cj@nospam.nosp am> wrote in news:et******** ******@TK2MSFTN GP12.phx.gbl:
Strangely next to
the non existent loop/continue statement goto would seem to create the
most readable and compact code.


Yebbut, Nobbut, Yebbut, Nobbut Yeah, you see... it's all about how far the
Goto GetOutOfHereNow is from the :GetOutOfHereNo w. In many implementations
they end up a long way away, and it's the code-maintainer that comes along
later and doesn't spot it.

For my money, structured programming is all about putting code into little
self-contained boxes, and any path that suddenly arrives at another point
with several different possibilities for variables that have been
initialised or not, files that have been opened or closed or not, etc etc
is asking for trouble. YMMV of course.

All the best
Tim F

Mar 16 '06 #32
cj
Very true. I'd add that not only is it bad practice to have a GoTo too
far from the label, it is just as bad to have too many lines of code
within an if, loop, do or whatever statement. If the top and bottom of
the code are close enough to be enclosed in a do loop the goto wouldn't
be a problem.

Also lets not forget what others have pointed out as well. Proper
naming is critical in anything. GoTo GetOutOfhere Now wouldn't be as
nice as GoTo BottomOfContinu eLoop assuming I'm using Do, While Continue
as the loop. Heck for that matter Continue is a bad choice of names in
most situations. It'd be better to use Do, While GetNewShippingR ecords
or something. Except that Continue is easily readable and
understandable in this specific app.

I'd further mention, and it's a pet peeve of mine, that I've seen these
little self contained boxes used to the point that they make code
unreadable. Some folks, and I'm not insinuating your one of them, use
them to such a point that he main code has nothing in it but calls and
then you find all it does is call others. Your jumping all over the
place to see what the next subroutine does and it becomes its own form
of spaghetti code. If you don't have to call a routine but from one
place you might not need to put it in a routine. Might, I said.
Sometimes it's good of course, like to remove a huge section of distinct
code to keep routines short enough to read.
Tim Ferguson wrote:
cj <cj@nospam.nosp am> wrote in news:et******** ******@TK2MSFTN GP12.phx.gbl:
Strangely next to
the non existent loop/continue statement goto would seem to create the
most readable and compact code.


Yebbut, Nobbut, Yebbut, Nobbut Yeah, you see... it's all about how far the
Goto GetOutOfHereNow is from the :GetOutOfHereNo w. In many implementations
they end up a long way away, and it's the code-maintainer that comes along
later and doesn't spot it.

For my money, structured programming is all about putting code into little
self-contained boxes, and any path that suddenly arrives at another point
with several different possibilities for variables that have been
initialised or not, files that have been opened or closed or not, etc etc
is asking for trouble. YMMV of course.

All the best
Tim F

Mar 16 '06 #33

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

Similar topics

3
2247
by: F. GEIGER | last post by:
When I start a py2exe-ed application I get the error 'ascii' codec can't encode character u'\xe9' in position 10: ordinal not in range(128) This is how I run py2exe: setup.py py2exe -O1 --packages encodings This is how the .po-file looks like:
2
1285
by: John Bailo | last post by:
Doing some c# client programming in VS.net One thing I miss is that in the code view I could set the focus to a form object in the left hand drop down ( like a TreeView control ) and then the right hand drop down would expose only the properties and events associated with that control. I don't see that in VS.NET
8
1405
by: ibm_97 | last post by:
DB2 8.2 I try to add a column into a table. I think the procedure inside DB2 is: 1. Create a temporary table which has the old table stucture and data. 2. Drop the original table 3. Create the new table with the added column 4. Insert data back into the new table from that temporary table.
7
1893
by: [Yosi] | last post by:
Hi, I create a thread which load DLL and have DLL function call,this Dll function takes a lot of time. My Question is , if I request Thread.Susspend(), and the thread is inside the Dll function (Dll function not finished yet, and thread function wait for this function (DLL)call to compleate), what will happen ? is this will susspend also the Dll function execution ? or will delay the susspend untill this function returned ? Thx
1
1532
by: kmounkhaty | last post by:
Hi Guru, My profiler trace does not display SP:CACHEMISS event, even thought I drop store proc, clear both data cache and buffer cache but still does not work. Every thing works fine like: cachehit, cacheinsert,cacheremove,executecontexthit etc... Is there any special option that I need to turn it on?
28
1726
by: Useful Info | last post by:
Like on 9/11, the Federal Government apparently WANTED people to die at the hands of Cho at VA Tech, because they told campus police not to pursue Cho after the double homicide occurred. Story via http://Muvy.org
8
12913
by: anukedari | last post by:
Hi, Could any boby please help to get the answers for the following questions: Is Apache always sends "X-Cache:MISS" header even when caching is off (disable)? or Can we say that cache settings are enable if it sends "X-Cache:MISS" header in the response? Your help would be appreciated.
0
1399
by: manikandan | last post by:
dont miss it just open dont miss it just open dont miss it just open #############################
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.