home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol080 / sample-c.bas < prev    next >
Encoding:
BASIC Source File  |  1984-04-29  |  1.1 KB  |  36 lines

  1. Rem   Sample program in CBASIC-2 to count to 10,000
  2.  
  3. %NOLIST   Rem    Suppress listing for better compiler speed
  4.  
  5. Rem   NOTE that the obvious way of testing for even multiples of 1000
  6. Rem    (in the loop in version 2 of the program), using the INT function,
  7. Rem    will not work with CBASIC-2 (every number gets printed), and that
  8. Rem    using floating-point variables (no "%" added to names), with which
  9. Rem    the INT function will work, gives a program that is INCREDIBLY slow:
  10. Rem    over 7 minutes (!) on my North Star. This is the reason for the
  11. Rem    somewhat convoluted logic in the version appearing below.
  12.  
  13. Rem   Define constants (as integer variables for speed):
  14.     Start.number% = 1
  15.     End.number% = 10000
  16.     Interval% = 1000
  17.  
  18.   Print Chr$ (7); "Counting program in CBASIC-2"
  19.   Print
  20.   Input "Press <RETURN> to start: "; LINE Go$
  21.   Print
  22.   Print "Counting ..."
  23.   Print
  24.  
  25.   FOR Number% = Start.number% TO End.number%
  26. Rem   (Remove next two "Rem's" for version 2 of the program)
  27. Rem IF (Number% / Interval%) * Interval% = Number% THEN \
  28. Rem   Print Number%
  29.   NEXT Number%
  30.   Print
  31.  
  32.   Print Chr$ (7); "Finished -- Good-bye"
  33.   Print
  34.  
  35. END
  36.