The following example prints an invoice. The main loop reads the order record and prints the invoice until there are no more orders to read. After printing date and name and addresses, the program prints a variable number of line items. The code that prints the line items is contained in a loop and repeated as many times as required.
Loops are accomplished by various programming structures that have a beginning, body and end. The beginning generally tests the condition that keeps the loop going. The body comprises the repeating statements, and the end is a GOTO that points back to the beginning. In assembly language, the programmer writes the GOTO, as in the following example that counts to 10.
MOVE "0" TO COUNTER
LOOP ADD "1" TO COUNTER
COMPARE COUNTER TO "10"
GOTO LOOP IF UNEQUAL
STOP
In high-level languages, the GOTO is generated by the interpreter or compiler; for example, the same routine as above using a WHILE loop.
COUNTER = 0
DO WHILE COUNTER <> 10
COUNTER = COUNTER + 1
ENDDO
STOP
For a more detailed look at a loop, look at the end of the C definition. The main event loop of the DOS version of this database is presented.
![]() | Reproduced with permission from Computer Desktop Encyclopedia. Copyright (c) 1981-2008 The Computer Language Company Inc. All rights reserved. |
Additional Resources
- iPhone vs. Android development: Day 1
- As I mentioned last week I've started learning more about developing for the Apple iPhone. This week I'll be sharing my experiences during a 5-day course on iPhone programming presented by Joe Conway from Big Nerd Ranch. In particular, I'll be pointing out differences between Android and iPhone development. ...
- Blog posts 2008-11-17
- Beatmaker for iPhone
- Intua's BeatMaker (US$20, iTunes) bills itself as a "mobile music creation studio" for the iPhone and iPod touch. It's a revolutionary application that allows you to easily create and edit beats and loops in the palm of your hand. After using it a little it becomes so...
- Blog posts 2008-11-13
- Live Webcast: The Mobile Workforce: Who is it? What's driving it? How do you manage it?
- As the mobile workforce trend continues to grow (IDC predicts there will be 1 billion mobile workers by 2011), business managers and organizations need to embrace practices and technologies that support this movement and enable workers to communicate and collaborate effectively over long distances. Join the live...
- Webcasts 2008-11-11
- How to scale to 256 processors and beyond
- How to scale to 256 processors and beyondSo in other words expecting MS to get this right is...basically a pie in the sky.Still chasing what Linux can already do...Learn from the lessons and heartache of BeOSOne of the biggest problems for BeOS as a development environment was lock and race...
- Discussion threads 2008-11-07
- News to know: E-voting security; Salesforce.com; NetSuite; SAP; Microsoft
- Here are today's notable headlines. You can get News To Know via email alert and RSS daily: Jason Perlow: Linux: The Joe Sixpack Strategy Mary Jo Foley: Microsoft Big Brains: Brad Lovering Microsoft confirms MinWin is in Windows 7, after all...
- Blog posts 2008-11-04
- Happy 20th birthday, internet worm!
- Happy 20th birthday, internet worm!Thanks for the history...Thanks for the history, but I don't think I'll be drinking in celebration this Nov. 2nd... I'll be drinking that day to ease the pain of removing all that junk off my computer... lol...Ah, the start of the rot began where?[i]"On November 2nd,...
- Discussion threads 2008-10-31
- Sony Ericsson W980 - black (unlocked)
- Photo gallery:Sony Ericsson W980Ten months ago, Sony Ericsson made a big splash at the GSMA World Congress in Barcelona when it introduced a gallery of flashy new phones. True to its usual form, the company focused on multimedia, with new additions to the Walkman and Cybershot series. Even then, we...
- Product reviews 2008-10-27
- Associative arrays and elections data
- Associative arrays and elections dataThis is a very useful data structureand what modern language doesnt provide an implementation of it?Neat as your solution it, I have say though I think you're a little hard on SQL. As this data is probably in a RDMBS anyway, if you can write a...
- Discussion threads 2008-10-25
- Momentum Webcast: Creating a Green Technology Refresh Plan for HP and Microsoft Solutions (Level 200)
- This webcast builds on the Hewlett-Packard HP Closed Loop Lifecycle Planning methodology to create a technology refresh plan for HP-based Microsoft solutions that embrace innovation and take advantage of cost reduction, cost avoidance, and service-level improvement strategies. The Closed Loop Lifecycle Planning methodology is proven to be successful in enabling...
- Webcasts 2008-10-23
- Adobe's Serious Magic site SQL Injected by Asprox botnet
- According to SophosLabs Adobe's owned seriousmagic.com has been automatically SQL injected by the Asprox botnet, becoming the very latest high profile legitimate web sites injected with links to exploits and malware serving sites : "The infection, which resides at hxxp://www.seriousmagic.com/help/tuts/tutorials.cfm?p=1, instructs users browsers to silently install a malicious file...
- Blog posts 2008-10-16
- Flower robots for your home
- Flower robots for your homeI can now say......that I have heard it all.Seems like I say that at least a few times a week, though.Really, a flower robot? Is this really necessary? This sounds like the plant equivalent of that stupid singing mounted bass.RE: Flower robots for your...
- Discussion threads 2008-10-16
- Ultimate Producer Series Hip Hop Loops (zip)
- The collection contains over 40 megabytes of hot royalty-free hip hop loops, drum loops, and other urban elements that will help you take your game to the next level. Files are recorded at 44.1/24 bit. Loops feature the real sounds, progressions, and beats in the styles of today's hottest chart...
- Software downloads 2008-10-15
- Facebook as social rule of thumb?
- Facebook as social rule of thumb?From a different perspective...In some respects, I think Facebook also lends itself towards those who were never woefully successful at being social in the real world, but could feel like they were in the virtual one. More real than IM with people you'll never meet,...
- Discussion threads 2008-10-13
- BI Crystal Ball – Next Gen BI May Be Closer Than You Think
- Most modern large enterprise Business Intelligence BI tools are very robust and feature rich these days. Up until a few years ago BI users could blame vendors for most of their BI ills. This is getting harder and harder to do. Many of the BI tools, especially the ones reviewed...
- Blog posts 2008-10-07
- Dance eJay (zip)
- eJay's Dance offers 5,000 new royalty-free sounds (samples, loops, beats and patches), many effects (eg. echo, chorus, reverb, compressor), new instruments (eg. Sample Loop Player, Drum Machine, Poly Synth and Bass Synth) and a completely redesigned interface. Creating a Dance hit has never been easier. This version is the first...
- Software downloads 2008-10-06
- Techno eJay (zip)
- eJay's Techno offers 5,000 new royalty-free sounds (samples, loops, beats and patches), many effects (eg. echo, chorus, reverb, compressor), new instruments (eg. Sample Loop Player, Drum Machine, Poly Synth and Bass Synth) and a completely redesigned interface. Creating a Techno hit has never been easier. This version is the first...
- Software downloads 2008-10-06
- Hiphop eJay (zip)
- Jay's Hiphop offers 5,000 new royalty-free sounds (samples, loops, beats and patches), many effects (eg. echo, chorus, reverb, compressor), new instruments (eg. Sample Loop Player, Drum Machine, Poly Synth and Bass Synth) and a completely redesigned interface. Creating a Hiphop hit has never been easier. This version is the first...
- Software downloads 2008-10-06
- Virtual Music Studio (eJay) (zip)
- eJay's Virtual Music Studio offers 15,000 new royalty-free sounds (samples, loops, beats and patches), many effects (eg. echo, chorus, reverb, compressor), new instruments (eg. Sample Loop Player, Drum Machine, Poly Synth and Bass Synth) and a completely redesigned interface. Creating a hit has never been easier. This version is the...
- Software downloads 2008-10-06
- 39 Traffic Jam Cell Cams (Windows Mobile) (CAB)
- The 39 Traffic Jam Cell Cams is a free cell phone application that gives you direct access to over 600 live, roadside traffic cameras in and around the Houston, TX metro area. Just download the software into your data enabled cell phone and before your next trip around the corner...
- Software downloads 2008-10-03
- 39 Traffic Jam Cell Cams (Palm) (prc)
- The 39 Traffic Jam Cell Cams is a free cell phone application that gives you direct access to over 600 live, roadside traffic cameras in and around the Houston, TX metro area. Just download the software into your data enabled cell phone and before your next trip around the corner...
- Software downloads 2008-10-03
Neighboring Terms
Premier Vendor Content Whitepapers, webcasts & resources from our Power Center Sponsors
- Learn how the latest Intel and industry best practices can improve your IT organization
-
Designed specifically to address the concerns of senior IT managers at organizations with more than 100 employees, the Intel Premier IT Professional Program provides best practices via local and e-Seminars and a members-only Web site.
- View the Intel Premier IT Professional web-site tour >>
All-in-One Printers
- 10 things to look for in an all-in-one printer A multifunction printer may offer the convenient, consolidated functionality your organization needs, but there are a lot of choices out there. Before making a selection, be sure to consider these key factors.
- From our sponsors
- HP Small Business LaserJet Printers
- HP Laser Jet M3035 MFP series Starting at $1,599. SHOP NOW
- New HP Color LaserJet CP3525n Printer Starting at $699. SHOP NOW



