ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

73 lines
2.1 KiB

  1. 10 PRINT "DAY BETWEEN TWO DATES"
  2. 20 PRINT
  3. 25 PRINT "USE MM,DD,YYYY"
  4. 29 REM - STATEMENTS 30 TO 60 REQUEST USER INPUT
  5. 30 PRINT "FIRST DATE";
  6. 40 INPUT M1,D1,Y1
  7. 50 PRINT "SECOND DATE";
  8. 60 INPUT M2,D2,Y2
  9. 69 REM - SET VARIABLES TO BE USED IN SUBROUTINE
  10. 70 M=M1
  11. 80 D=D1
  12. 90 Y=Y1
  13. 100 GOSUB 230
  14. 109 REM - SAVE COMPUTED NUMBER OF DAYS IN N
  15. 110 N=A
  16. 119 REM - SET VARIABLES TO BE USED IN SUBROUTINE
  17. 120 M=M2
  18. 130 D=D2
  19. 140 Y=Y2
  20. 150 GOSUB 230
  21. 159 REM - CALCULATE DIFFERENCE AND PRINT
  22. 160 N=A-N
  23. 170 PRINT "DIFFERENCE =";N;"DAYS"
  24. 180 PRINT
  25. 189 REM - RESTART OR END PROGRAM?
  26. 190 PRINT "MORE DATA (1=YES, 0=NO)";
  27. 200 INPUT X
  28. 210 IF X=1 THEN 20
  29. 219 REM - END PROGRAM
  30. 220 GOTO 460
  31. 227 REM - SUBROUTINE TO COMPUTE NUMBER OF DAYS SINCE 0,0,0 TO M,D,Y
  32. 228 REM - START WITH TEST FOR UNREAL DATE
  33. 229 REM - GO TO CORRECT TEST DEPENDING ON NUMBER OF DAYS IN MONTH
  34. 230 ON M GOTO 260,280,260,340,260,340,260,260,340,260,340,260
  35. 239 REM - IF THIS MESSAGE IS PRINTED THE ANSWER IS PROBABLY INCORRECT
  36. 240 PRINT "UNREAL DATE"
  37. 249 REM - STOP CALCULATIONS, RETURN TO MAIN PROGRAM
  38. 250 RETURN
  39. 259 REM - MONTH HAS 31 DAYS
  40. 260 IF D>31 THEN 240
  41. 270 GOTO 350
  42. 279 REM - MONTH IS FEBRUARY; A LEAP YEAR?
  43. 280 IF Y/4=INT(Y/4) THEN 290
  44. 290 IF Y/400=INT(Y/400) THEN 320
  45. 300 IF Y/100=INT(Y/100) THEN 310
  46. 309 REM - NOT A LEAP YEAR; MONTH HAS 28 DAYS
  47. 310 IF D>28 THEN 240
  48. 319 REM - A LEAP YEAR; MONTH HAS 29 DAYS
  49. 320 IF D>29 THEN 240
  50. 330 GOTO 350
  51. 339 REM - MONTH HAS 30 DAYS
  52. 340 IF D>30 THEN 240
  53. 349 REM - TABLE OF NUMBER OF DAYS FROM 1ST OF YEAR TO 1ST OF EACH MONTH
  54. 350 DATA 0,31,59,90,120,151,181,212,243,273,304,334
  55. 360 RESTORE
  56. 369 REM - GET NUMBER OF DAYS FROM JAN 1 TO 1ST OF MONTH FROM DATA TABLE
  57. 370 READ A
  58. 379 REM - COMPUTE NUMBER OF DAYS FROM 0,0,0 TO M,D,Y
  59. 380 A=A+Y*365+INT(Y/4)+D+1-INT(Y/100)+INT(Y/400)
  60. 389 REM - POSSIBLY A LEAP YEAR?
  61. 390 IF INT(Y/4)=Y/4 THEN 410
  62. 400 GOTO 450
  63. 409 REM - CONTINUE TEST FOR LEAP YEAR
  64. 410 IF Y/400=INT(Y/400) THEN 430
  65. 420 IF Y/100=INT(Y/100) THEN 440
  66. 428 REM - YEAR IS A LEAP YEAR;
  67. 429 REM - IF MONTH IS JAN OR FEB ADJUST CALCULATED NUMBER OF DAYS
  68. 430 IF M>2 THEN 450
  69. 440 A=A-1
  70. 449 REM - END OF SUBROUTINE, RETURN TO MAIN PROGRAM
  71. 450 RETURN
  72. 460 END