nested do loops

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
pronoland
Newbie
Posts: 6
Joined: Sat Feb 10, 2007 1:16 pm
Location: FRIENDLY FRIDLEY MN USA

nested do loops

Post by pronoland »

HOW DO I:

K = O
DO WHILE K < 15
K=K+ 1
L=0
DO WHILE L <200
I(L) =0
LOOP
LOOP

END
HOW DOES basic know which loop goes with whichdo statement?
new user, but willing to learn
bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm »

Pretty easily after all.
Last DO what is stated, is cut by first LOOP.

Code: Select all

DO ' first
   DO ' second
     DO ' third

     LOOP ' third DO is last stated so its ended here
   DO ' third is now out so second DO is ended here
LOOP ' only first DO alive so we end it here.
So you cant end first DO, before third and second are ended.
Post Reply