home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / flow / exam13.dba < prev    next >
Encoding:
Text File  |  2000-01-24  |  1013 b   |  49 lines

  1. Rem * Title  : Using Functions
  2. Rem * Author : DBS-LB
  3. Rem * Date   : 1st Sept 99
  4. rem ===========================================================
  5. rem DARK BASIC EXAMPLE PROGRAM 13
  6. rem ===========================================================
  7. rem This program will show you how to use simple functions
  8. rem -----------------------------------------------------------
  9.  
  10. rem Call my own function as a command
  11. fillscreen(50)
  12.     
  13. rem Call my own function that returns a value
  14. print halfvalue(10)
  15.  
  16. rem Call my own function that exits early
  17. print doublevalue(10)
  18.  
  19. rem End of program
  20. end
  21.  
  22. rem Declare a command function
  23. function fillscreen(count)
  24.  
  25.     for t=1 to count
  26.         print t;", ";
  27.     next t
  28.  
  29. endfunction
  30.  
  31. rem Declare a function that returns a value
  32. function halfvalue(value)
  33.  
  34.     value=value/2
  35.  
  36. endfunction value
  37.  
  38. rem Declare a function that returns a value
  39. function doublevalue(value)
  40.  
  41.     value=value*2
  42.  
  43.     exitfunction value
  44.  
  45.     rem This line never happens
  46.     value=0
  47.  
  48. endfunction value
  49.