home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / flow / exam03.dba < prev    next >
Encoding:
Text File  |  1999-09-07  |  1.9 KB  |  84 lines

  1. Rem * Title  : DO LOOP Commands
  2. Rem * Author : DBS-MB
  3. Rem * Date   : 1st August 99
  4. rem ===========================================================
  5. rem DARK BASIC EXAMPLE PROGRAM 3
  6. rem ===========================================================
  7. rem This program will show you how to use LOOP commands
  8. rem -----------------------------------------------------------
  9.  
  10. rem Set the ink to white and paper color to black 
  11. ink rgb(244,214,210),1
  12.  
  13. rem the first loop we will look at is the DO LOOP
  14. rem this loop will loop for ever or until an EXIT command is used
  15.  
  16. variable=0
  17.  
  18. do
  19.  
  20.     rem clear the screen
  21.     cls 
  22.  
  23.     print "press the left mouse button to quit"
  24.     print "we have loop ",variable," times using a DO LOOP"
  25.         
  26.     rem add one to variable
  27.     variable=variable+1
  28.  
  29.     rem if you press left mouse button then exit from this loop
  30.     if mouseclick()=1:exit:endif
  31.  
  32. loop 
  33.  
  34. rem wait here till you release the mouse button
  35. repeat:until mouseclick()=0
  36.  
  37. rem the second type of loop is the REPEAT UNTIL 
  38. rem the loop will end when variable = number
  39. rem or a EXIT command is used
  40.  
  41. variable=0
  42. targetnumber=1000
  43.  
  44. repeat
  45.  
  46.     rem clear the screen
  47.     cls 
  48.  
  49.     print "press the left mouse button to quit"
  50.     print "we have loop ",variable," times using a REPEAT UNTIL loop"
  51.  
  52.     rem add one to variable
  53.     variable=variable+1
  54.  
  55.     rem if you press left mouse button then exit from this loop
  56.     if mouseclick()=1:exit:endif
  57.  
  58. until variable=numbertarget
  59.  
  60. rem wait here till you release the mouse button
  61. repeat:until mouseclick()=0
  62.  
  63. rem the third type of loop is the WHILE WEND
  64.     
  65. variable=0
  66. while variable<1000
  67.  
  68.     rem clear the screen
  69.     cls 
  70.  
  71.     print "press the left mouse button to quit"
  72.     print "we have loop ",variable," times using a WHILE ENDWHILE loop"
  73.  
  74.     rem add one to variable
  75.     variable=variable+1
  76.  
  77.     rem if you press left mouse button then exit from this loop
  78.     if mouseclick()=1:exit:endif
  79.  
  80. endwhile
  81.  
  82. rem End the program
  83. end
  84.