home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / flow / exam02.dba < prev    next >
Encoding:
Text File  |  2000-05-22  |  1.3 KB  |  57 lines

  1. Rem * Title  : FOR NEXT Commands
  2. Rem * Author : DBS-MB
  3. Rem * Date   : 1st August 99
  4. rem ===========================================================
  5. rem DARK BASIC EXAMPLE PROGRAM 2
  6. rem ===========================================================
  7. rem This program will show you how to use the FOR NEXT 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 there is two ways to use the FOR NEXT commands
  14. rem the first way is to use the FOR NEXT command is like this
  15.     
  16. rem will count upto 20
  17. print "COUNTING UP TO 20"  
  18. for t=0 to 20
  19.     print " ",t;
  20. next t
  21. print
  22.  
  23. rem will count down to 0
  24. print "COUNTING DOWN TO 0" 
  25. for t=20 to 0 step -1
  26.     print " ",t;
  27. next t
  28. print
  29.  
  30. rem to break out of a loop at any time use the EXIT command
  31. rem will count upto 20 
  32. print "BREAKING OUT OF A LOOP WHEN T = 15"
  33. for t=0 to 20
  34.     print " ",t;
  35.     if t=15 then print : print "I AM OUT OF HERE" : exit
  36. next t
  37. print
  38.  
  39. rem the second way to use the FOR NEXT command is like this
  40.  
  41. rem will count upto 20 in steps of 2
  42. print "COUNTING UP TO 20 IN STEP OF 2"
  43. for t=0 to 20 step 2
  44.     print " ",t;
  45. next t
  46. print 
  47.  
  48. rem will count down from 20 steps of 2
  49. print "COUNTING DOWN TO 20 IN STEP OF 2"
  50. for t=20 to 0 step -2
  51.     print " ",t;
  52. next t
  53. print 
  54.  
  55. rem End the program
  56. end
  57.