Author Topic: gwbasic's if statement doesn't work on qb64  (Read 4297 times)

0 Members and 1 Guest are viewing this topic.

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
gwbasic's if statement doesn't work on qb64
« on: January 04, 2021, 07:08:10 pm »
I'm talking about this code
Code: QB64: [Select]
  1. 10 PRINT TAB(32); "WEEKDAY"
  2. 20 PRINT TAB(15); "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  3. 100 PRINT "WEEKDAY IS A COMPUTER DEMONSTRATION THAT"
  4. 110 PRINT "DA FATTI SU UNA DATA DI INTERESSE PER VOI."
  5. 120 PRINT
  6. 130 PRINT "INSERISCI LA DATA DI OGGI NEL MODULO: 3,24,1979  ";
  7. 140 INPUT M1, D1, Y1
  8. 150 REM THIS PROGRAM DETERMINES THE DAY OF THE WEEK
  9. 160 REM  FOR A DATE AFTER 1582
  10. 180 DIM T(12)
  11.  
  12. 200 REM SPACE OUTPUT AND READ IN INITIAL VALUES FOR MONTHS.
  13. 210 FOR I = 1 TO 12
  14.    220 READ T(I)
  15. 230 NEXT I
  16. 240 PRINT "INSERISCI GIORNO DI NASCITA (O ALTRO GIORNO DI INTERESSE)";
  17. 250 INPUT M, D, Y
  18. 260 PRINT
  19. 270 LET I1 = INT((Y - 1500) / 100)
  20. 280 REM TEST FOR DATE BEFORE CURRENT CALENDAR.
  21. 290 IF Y - 1582 < 0 THEN 1300
  22. 300 LET A = I1 * 5 + (I1 + 3) / 4
  23. 310 LET I2 = INT(A - fnb(A) * 7)
  24. 320 LET Y2 = INT(Y / 100)
  25. 330 LET Y3 = INT(Y - Y2 * 100)
  26. 340 LET A = Y3 / 4 + Y3 + D + T(M) + I2
  27. 350 LET B = INT(A - fnb(A) * 7) + 1
  28. 360 IF M > 2 THEN 470
  29. 370 IF Y3 = 0 THEN 440
  30. 380 LET T1 = INT(Y - fna(Y) * 4)
  31. 390 IF T1 <> 0 THEN 470
  32. 400 IF B <> 0 THEN 420
  33. 410 LET B = 6
  34. 420 LET B = B - 1
  35. 430 GOTO 470
  36. 440 LET A = I1 - 1
  37. 450 LET T1 = INT(A - fna(A) * 4)
  38. 460 IF T1 = 0 THEN 400
  39. 470 IF B <> 0 THEN 490
  40. 480 LET B = 7
  41. 490 IF (Y1 * 12 + M1) * 31 + D1 < (Y * 12 + M) * 31 + D THEN 550
  42. 500 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 530
  43. 510 PRINT M; "/"; D; "/"; Y; " ERA UN ";
  44. 520 GOTO 570
  45. 530 PRINT M; "/"; D; "/"; Y; " E UN ";
  46. 540 GOTO 570
  47. 550 PRINT M; "/"; D; "/"; Y; " SARA UN ";
  48. 560 REM PRINT THE DAY OF THE WEEK THE DATE FALLS ON.
  49. 570 IF B <> 1 THEN 590
  50. 580 PRINT "DOMENICA."
  51. 590 IF B <> 2 THEN 610
  52. 600 PRINT "LUNEDI."
  53. 610 IF B <> 3 THEN 630
  54. 620 PRINT "MARTEDI."
  55. 630 IF B <> 4 THEN 650
  56. 640 PRINT "MERCOLEDI."
  57. 650 IF B <> 5 THEN 670
  58. 660 PRINT "GIOVEDI."
  59. 670 IF B <> 6 THEN 690
  60. 680 GOTO 1250
  61. 690 IF B <> 7 THEN 710
  62. 700 PRINT "SABATO."
  63. 710 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 1120
  64. 720 LET I5 = Y1 - Y
  65. 730 PRINT
  66. 740 LET I6 = M1 - M
  67. 750 LET I7 = D1 - D
  68. 760 IF I7 >= 0 THEN 790
  69. 770 LET I6 = I6 - 1
  70. 780 LET I7 = I7 + 30
  71. 790 IF I6 >= 0 THEN 820
  72. 800 LET I5 = I5 - 1
  73. 810 LET I6 = I6 + 12
  74. 820 IF I5 < 0 THEN 1310
  75. 830 IF I7 <> 0 THEN 850
  76. 835 IF I6 <> 0 THEN 850
  77. 840 PRINT "***HAPPY BIRTHDAY***"
  78. 850 PRINT " ", " ", "ANNI", "MESI", "GIORNI"
  79. 855 PRINT " ", " ", "-----", "------", "----"
  80. 860 PRINT "LA TUA ETA      ", I5, I6, I7
  81. 870 LET A8 = (I5 * 365) + (I6 * 30) + I7 + INT(I6 / 2)
  82. 880 LET K5 = I5
  83. 890 LET K6 = I6
  84. 900 LET K7 = I7
  85. 910 REM CALCULATE RETIREMENT DATE.
  86. 920 LET E = Y + 65
  87. 930 REM CALCULATE TIME SPENT IN THE FOLLOWING FUNCTIONS.
  88. 940 LET F = .35
  89. 950 PRINT "HAI DORMITO     ",
  90. 960 GOSUB 1370
  91. 970 LET F = .17
  92. 980 PRINT "TU HAI MANGIATO ",
  93. 990 GOSUB 1370
  94. 1000 LET F = .23
  95. 1010 IF K5 > 3 THEN 1040
  96. 1020 PRINT "HAI GIOCATO",
  97. 1030 GOTO 1080
  98. 1040 IF K5 > 9 THEN 1070
  99. 1050 PRINT "HAI GIOCATO / STUDIATO",
  100. 1060 GOTO 1080
  101. 1070 PRINT "HAI LAVORATO / GIOCATO",
  102. 1080 GOSUB 1370
  103. 1085 GOTO 1530
  104. 1090 PRINT "TI SEI RILASSATO ", K5, K6, K7
  105. 1100 PRINT
  106. 1110 PRINT TAB(16); "***  PUOI ANDARE IN PENSIONE"; E; " ***"
  107. 1120 PRINT
  108. 1140 PRINT
  109. 1200 PRINT
  110. 1210 PRINT
  111. 1220 PRINT
  112. 1230 PRINT
  113. 1240 END
  114. 1250 IF D = 13 THEN 1280
  115. 1260 PRINT "VENERDI."
  116. 1270 GOTO 710
  117. 1280 PRINT "VENERDI TREDICESIMO --- ATTENZIONE!"
  118. 1290 GOTO 710
  119. 1300 PRINT "NON PREPARATI A DARE GIORNO DELLA SETTIMANA PRIMA DI MDLXXXII. "
  120. 1310 GOTO 1140
  121. 1320 REM TABLE OF VALUES FOR THE MONTHS TO BE USED IN CALCULATIONS.
  122. 1330 DATA 0,3,3,6,1,4,6,2,5,0,3,5
  123. 1340 REM THIS IS THE CURRENT DATE USED IN THE CALCULATIONS.
  124. 1350 REM THIS IS THE DATE TO BE CALCULATED ON.
  125. 1360 REM CALCULATE TIME IN YEARS, MONTHS, AND DAYS
  126. 1370 LET K1 = INT(F * A8)
  127. 1380 LET I5 = INT(K1 / 365)
  128. 1390 LET K1 = K1 - (I5 * 365)
  129. 1400 LET I6 = INT(K1 / 30)
  130. 1410 LET I7 = K1 - (I6 * 30)
  131. 1420 LET K5 = K5 - I5
  132. 1430 LET K6 = K6 - I6
  133. 1440 LET K7 = K7 - I7
  134. 1450 IF K7 >= 0 THEN 1480
  135. 1460 LET K7 = K7 + 30
  136. 1470 LET K6 = K6 - 1
  137. 1480 IF K6 > 0 THEN 1510
  138. 1490 LET K6 = K6 + 12
  139. 1500 LET K5 = K5 - 1
  140. 1510 PRINT I5, I6, I7
  141. 1520 RETURN
  142. 1530 IF K6 = 12 THEN 1550
  143. 1540 GOTO 1090
  144. 1550 LET K5 = K5 + 1
  145. 1560 LET K6 = 0
  146. 1570 GOTO 1090
  147. 1580 REM
  148. 1590 END
  149. FUNCTION fna (A)
  150.     fna = INT(A / 4)
  151. FUNCTION fnb (A)
  152.     fnb = INT(A / 4)


this is the code that I think does not execute well
Code: QB64: [Select]
  1. 550 PRINT M; "/"; D; "/"; Y; " SARA UN ";
  2. 560 REM PRINT THE DAY OF THE WEEK THE DATE FALLS ON.
  3. 570 IF B <> 1 THEN 590
  4. 580 PRINT "DOMENICA."
  5. 590 IF B <> 2 THEN 610
  6. 600 PRINT "LUNEDI."
  7. 610 IF B <> 3 THEN 630
  8. 620 PRINT "MARTEDI."
  9. 630 IF B <> 4 THEN 650
  10. 640 PRINT "MERCOLEDI."
  11. 650 IF B <> 5 THEN 670
  12. 660 PRINT "GIOVEDI."
  13. 670 IF B <> 6 THEN 690
  14. 680 GOTO 1250
  15. 690 IF B <> 7 THEN 710
  16. 700 PRINT "SABATO."
  17. 710 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 1120
  18. 720 LET I5 = Y1 - Y
  19. 730 PRINT

because when I run the program it should tell me if it was a Sunday or a Monday or a Tuesday any day after the if statement why shouldn't it be executed?


i know it's old code but i am using this to learn and understand better
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #1 on: January 04, 2021, 07:53:23 pm »
The only thing to learn from that is how NOT to do things like that anymore.
Granted after becoming radioactive I only have a half-life!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #2 on: January 04, 2021, 07:55:50 pm »
I'm with Cobalt. This code should just be "looked at", not "read".
You're not done when it works, you're done when it's right.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #3 on: January 04, 2021, 08:20:59 pm »
Use SELECT CASE, instead of IF/THEN, as in: SELECT CASE of dynamite and blow that code to hell.

Code: QB64: [Select]
  1. B = 3
  2. PRINT "Monday"
  3. PRINT "Tuesday"
  4. PRINT "Wednesday"
  5. PRINT "Thursday"
  6. PRINT "Friday"
  7. PRINT "Saturday"
  8. PRINT "Sunday"

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: gwbasic's if statement doesn't work on qb64
« Reply #4 on: January 04, 2021, 08:47:54 pm »
Or toss that whole program.

Code: QB64: [Select]
  1.  
  2. INPUT “Enter month”, m
  3. INPUT “Enter day”, d
  4. INPUT “Enter year (all 4 digits”, y
  5.  
  6. PRINT GetDay$(m, d, y)
  7.  
  8. FUNCTION GetDay$ (m, d, y) 'use 4 digit year
  9.     'From Zeller's congruence: https://en.wikipedia.org/wiki/Zeller%27s_congruence
  10.     mm = m: dd = d: yyyy = y
  11.     IF mm < 3 THEN mm = mm + 12: yyyy = yyyy - 1
  12.     century = yyyy MOD 100
  13.     zerocentury = yyyy \ 100
  14.     result = (dd + INT(13 * (mm + 1) / 5) + century + INT(century / 4) + INT(zerocentury / 4) + 5 * zerocentury) MOD 7
  15.     'Function changed to return a numeric value instead of a string for this program
  16.         SELECT CASE result
  17.             CASE 0: GetDay$ = "Saturday"
  18.             CASE 1: GetDay$ = "Sunday"
  19.             CASE 2: GetDay$ = "Monday"
  20.             CASE 3: GetDay$ = "Tuesday"
  21.             CASE 4: GetDay$ = "Wednesday"
  22.             CASE 5: GetDay$ = "Thursday"
  23.             CASE 6: GetDay$ = "Friday"
  24.         END SELECT
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #5 on: January 04, 2021, 08:57:24 pm »
Hey what's this saying about this date?

  [ You are not allowed to view this attachment ]  

I think GWBasic's IF works fine in QB64 :)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #6 on: January 04, 2021, 09:16:46 pm »
Kiara did you add this onto the end of the Morristown code because QB64 does not do DEF FN... ?

Code: QB64: [Select]
  1. FUNCTION fna (A)
  2.     fna = INT(A / 4)
  3. FUNCTION fnb (A)
  4.     fnb = INT(A / 4)
  5.  

This does not look right, why define two functions that do exactly the same thing? That's wasting time.

I suspect fna() was suppose to calculate something different than fnb().

Looks like a leap year calculation where these are being used?
« Last Edit: January 04, 2021, 09:23:21 pm by bplus »

Offline Adrian

  • Newbie
  • Posts: 39
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #7 on: January 04, 2021, 11:47:51 pm »
GWBASIC... what memories :)
« Last Edit: January 04, 2021, 11:58:05 pm by Adrian »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: gwbasic's if statement doesn't work on qb64
« Reply #8 on: January 04, 2021, 11:48:04 pm »
Best I can tell, now that I'm at home and have a had a chance to look at this, the code itself is simply buggy somewhere.

The reason why we're not seeing any date being printed, is simply because we're not generating a day value from 1 to 7, as I illustrate here:

Code: QB64: [Select]
  1. 10 PRINT TAB(32); "WEEKDAY"
  2. 20 PRINT TAB(15); "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  3. 100 PRINT "WEEKDAY IS A COMPUTER DEMONSTRATION THAT"
  4. 110 PRINT "FROM FACTS ON A DATE OF INTEREST FOR YOU."
  5. 120 PRINT
  6. 130 PRINT "ENTER THE DATE OF TODAY IN THE FORM: 3,24,1979  ";
  7. 140 INPUT M1, D1, Y1
  8. 150 REM THIS PROGRAM DETERMINES THE DAY OF THE WEEK
  9. 160 REM  FOR A DATE AFTER 1582
  10. 180 DIM T(12)
  11.  
  12. 200 REM SPACE OUTPUT AND READ IN INITIAL VALUES FOR MONTHS.
  13. 210 FOR I = 1 TO 12
  14.    220 READ T(I)
  15. 230 NEXT I
  16. 240 PRINT "ENTER DAY OF BIRTH (OR OTHER DAY OF INTEREST)";
  17. 250 INPUT M, D, Y 'let's say I'm going to use 1, 1, 2021
  18. 260 PRINT
  19. 270 LET I1 = INT((Y - 1500) / 100) 'so 5 for 2021?
  20. 280 REM TEST FOR DATE BEFORE CURRENT CALENDAR.
  21. 290 IF Y - 1582 < 0 THEN 1300
  22. 300 LET A = I1 * 5 + (I1 + 3) / 4 '5 * 5 + 8 / 4 = 25 + 2 = 27
  23. 310 LET I2 = INT(A - fnb(A) * 7) 'int (27 - 6 * 7) = 27 - 42 = -15
  24. 320 LET Y2 = INT(Y / 100) '20
  25. 330 LET Y3 = INT(Y - Y2 * 100) 'int(2021 - 20 * 100) = 21
  26. 340 LET A = Y3 / 4 + Y3 + D + T(M) + I2 'WAIT??  WHAT?? Why did we calculate A before, just to replace it completely here??
  27. ' A = 21 / 4 + 21 + 1 + T(M) + (-15)
  28. ' T(1) = 0 for the above, so A = 5 + 21 + 1 + 0 - 15
  29. ' Which makes A = 12?
  30. 350 LET B = INT(A - fnb(A) * 7) + 1 '12 - 3 * 7 = `12 - 21 = -9
  31. 360 IF M > 2 THEN 470 'month is only 1; skip this
  32. 370 IF Y3 = 0 THEN 440 'y3 is 21; skip this
  33. 380 LET T1 = INT(Y - fna(Y) * 4) 'T1 = 2021 - 504 * 4 = 1
  34. 390 IF T1 <> 0 THEN 470 'T1 = 1, so we goto 470
  35. 400 IF B <> 0 THEN 420
  36. 410 LET B = 6
  37. 420 LET B = B - 1
  38. 430 GOTO 470
  39. 440 LET A = I1 - 1
  40. 450 LET T1 = INT(A - fna(A) * 4)
  41. 460 IF T1 = 0 THEN 400
  42. 470 IF B <> 0 THEN 490 'B = -9, so we goto 490
  43. 480 LET B = 7
  44. 490 IF (Y1 * 12 + M1) * 31 + D1 < (Y * 12 + M) * 31 + D THEN 550 'these just gives us a formatting for grammer
  45. 500 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 530 'both end up going to 570
  46. 510 PRINT M; "/"; D; "/"; Y; " WAS A "; B
  47. 520 GOTO 570
  48. 530 PRINT M; "/"; D; "/"; Y; " IT'S A "; B
  49. 540 GOTO 570
  50. 550 PRINT M; "/"; D; "/"; Y; " IT WILL BE A "; B
  51. 560 REM PRINT THE DAY OF THE WEEK THE DATE FALLS ON.
  52. 570 IF B <> 1 THEN 590 '-9 is not 1, so goto 590
  53. 580 PRINT "SUNDAY."
  54. 590 IF B <> 2 THEN 610 '-9 is not 2, so goto 610
  55. 600 PRINT "MONDAY."
  56. 610 IF B <> 3 THEN 630 '-9 is not 3, so goto 630
  57. 620 PRINT "TUESDAY."
  58. 630 IF B <> 4 THEN 650 '-9 is not 4, so goto 650
  59. 640 PRINT "WEDNESDAY."
  60. 650 IF B <> 5 THEN 670 '-9 is not 5, so goto 670
  61. 660 PRINT "THURSDAY."
  62. 670 IF B <> 6 THEN 690 '-9 is not 6, so goto 690
  63. 680 GOTO 1250
  64. 690 IF B <> 7 THEN 710 '-9 is not 7, so goto 710
  65. 700 PRINT "SATURDAY."
  66. 710 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 1120
  67. 720 LET I5 = Y1 - Y
  68. 730 PRINT
  69. 740 LET I6 = M1 - M
  70. 750 LET I7 = D1 - D
  71. 760 IF I7 >= 0 THEN 790
  72. 770 LET I6 = I6 - 1
  73. 780 LET I7 = I7 + 30
  74. 790 IF I6 >= 0 THEN 820
  75. 800 LET I5 = I5 - 1
  76. 810 LET I6 = I6 + 12
  77. 820 IF I5 < 0 THEN 1310
  78. 830 IF I7 <> 0 THEN 850
  79. 835 IF I6 <> 0 THEN 850
  80. 840 PRINT "***HAPPY BIRTHDAY***"
  81. 850 PRINT " ", " ", "ANNI", "MESI", "GIORNI"
  82. 855 PRINT " ", " ", "-----", "------", "----"
  83. 860 PRINT "LA TUA ETA      ", I5, I6, I7
  84. 870 LET A8 = (I5 * 365) + (I6 * 30) + I7 + INT(I6 / 2)
  85. 880 LET K5 = I5
  86. 890 LET K6 = I6
  87. 900 LET K7 = I7
  88. 910 REM CALCULATE RETIREMENT DATE.
  89. 920 LET E = Y + 65
  90. 930 REM CALCULATE TIME SPENT IN THE FOLLOWING FUNCTIONS.
  91. 940 LET F = .35
  92. 950 PRINT "HAI DORMITO     ",
  93. 960 GOSUB 1370
  94. 970 LET F = .17
  95. 980 PRINT "TU HAI MANGIATO ",
  96. 990 GOSUB 1370
  97. 1000 LET F = .23
  98. 1010 IF K5 > 3 THEN 1040
  99. 1020 PRINT "HAI GIOCATO",
  100. 1030 GOTO 1080
  101. 1040 IF K5 > 9 THEN 1070
  102. 1050 PRINT "HAI GIOCATO / STUDIATO",
  103. 1060 GOTO 1080
  104. 1070 PRINT "HAI LAVORATO / GIOCATO",
  105. 1080 GOSUB 1370
  106. 1085 GOTO 1530
  107. 1090 PRINT "TI SEI RILASSATO ", K5, K6, K7
  108. 1100 PRINT
  109. 1110 PRINT TAB(16); "***  PUOI ANDARE IN PENSIONE"; E; " ***"
  110. 1120 PRINT
  111. 1140 PRINT
  112. 1200 PRINT
  113. 1210 PRINT
  114. 1220 PRINT
  115. 1230 PRINT
  116. 1240 END
  117. 1250 IF D = 13 THEN 1280
  118. 1260 PRINT "FRIDAY."
  119. 1270 GOTO 710
  120. 1280 PRINT "FRIDAY THE 13TH -- ATTENTION!"
  121. 1290 GOTO 710
  122. 1300 PRINT "NON PREPARATI A DARE GIORNO DELLA SETTIMANA PRIMA DI MDLXXXII. "
  123. 1310 GOTO 1140
  124. 1320 REM TABLE OF VALUES FOR THE MONTHS TO BE USED IN CALCULATIONS.
  125. 1330 DATA 0,3,3,6,1,4,6,2,5,0,3,5
  126. 1340 REM THIS IS THE CURRENT DATE USED IN THE CALCULATIONS.
  127. 1350 REM THIS IS THE DATE TO BE CALCULATED ON.
  128. 1360 REM CALCULATE TIME IN YEARS, MONTHS, AND DAYS
  129. 1370 LET K1 = INT(F * A8)
  130. 1380 LET I5 = INT(K1 / 365)
  131. 1390 LET K1 = K1 - (I5 * 365)
  132. 1400 LET I6 = INT(K1 / 30)
  133. 1410 LET I7 = K1 - (I6 * 30)
  134. 1420 LET K5 = K5 - I5
  135. 1430 LET K6 = K6 - I6
  136. 1440 LET K7 = K7 - I7
  137. 1450 IF K7 >= 0 THEN 1480
  138. 1460 LET K7 = K7 + 30
  139. 1470 LET K6 = K6 - 1
  140. 1480 IF K6 > 0 THEN 1510
  141. 1490 LET K6 = K6 + 12
  142. 1500 LET K5 = K5 - 1
  143. 1510 PRINT I5, I6, I7
  144. 1520 RETURN
  145. 1530 IF K6 = 12 THEN 1550
  146. 1540 GOTO 1090
  147. 1550 LET K5 = K5 + 1
  148. 1560 LET K6 = 0
  149. 1570 GOTO 1090
  150. 1580 REM
  151. 1590 END
  152. FUNCTION fna (A)
  153.     fna = INT(A / 4)
  154. FUNCTION fnb (A)
  155.     fnb = INT(A / 4)
  156.  

By running the program, we generate a B value for the day, and our calculation ends up returning negative values to us.  (For 1/1/2021, the value ends up telling us that our day is the -9th day, which is completely meaningless.)  Now, what's glitched here, I have no clue.  Perhaps, it's like STx has suggested and one of the FUNCTIONS is wrong, or perhaps it's something else completely.  If you've translated this code from some original QB45 source, kindly share the source so we can compare the two versions, otherwise, I'm afraid, about all you can get here is some basic confirmation:  "Yep, it's buggy."

The IF statements work fine; but there's something in the math that simply doesn't compute properly, as written.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Adrian

  • Newbie
  • Posts: 39
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #9 on: January 05, 2021, 03:06:11 am »
ok, i think the problem was function fnb(A). changing it to fnb=INT(A/7) seems to work.

Code: QB64: [Select]
  1. 10 PRINT TAB(32); "WEEKDAY"
  2. 20 PRINT TAB(15); "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  3. 100 PRINT "WEEKDAY IS A COMPUTER DEMONSTRATION THAT"
  4. 110 PRINT "FROM FACTS ON A DATE OF INTEREST FOR YOU."
  5. 120 PRINT
  6. 130 PRINT "ENTER THE DATE OF TODAY IN THE FORM (M,D,Y): 3,24,1979  ";
  7. 140 INPUT M1, D1, Y1
  8. 150 REM THIS PROGRAM DETERMINES THE DAY OF THE WEEK
  9. 160 REM  FOR A DATE AFTER 1582
  10. 180 DIM T(12)
  11.  
  12. 200 REM SPACE OUTPUT AND READ IN INITIAL VALUES FOR MONTHS.
  13. 210 FOR I = 1 TO 12
  14.    220 READ T(I)
  15. 230 NEXT I
  16. 240 PRINT "ENTER DAY OF BIRTH (OR OTHER DAY OF INTEREST)";
  17. 250 INPUT M, D, Y
  18. 260 PRINT
  19. 270 LET I1 = INT((Y - 1500) / 100)
  20. 280 REM TEST FOR DATE BEFORE CURRENT CALENDAR.
  21. 290 IF Y - 1582 < 0 THEN 1300
  22. 300 LET A = I1 * 5 + (I1 + 3) / 4
  23. 310 LET I2 = INT(A - fnb(A) * 7)
  24. 320 LET Y2 = INT(Y / 100)
  25. 330 LET Y3 = INT(Y - Y2 * 100)
  26. 340 LET A = Y3 / 4 + Y3 + D + T(M) + I2
  27. 350 LET B = INT(A - fnb(A) * 7) + 1
  28. 360 IF M > 2 THEN 470
  29. 370 IF Y3 = 0 THEN 440
  30. 380 LET T1 = INT(Y - fna(Y) * 4)
  31. 390 IF T1 <> 0 THEN 470
  32. 400 IF B <> 0 THEN 420
  33. 410 LET B = 6
  34. 420 LET B = B - 1
  35. 430 GOTO 470
  36. 440 LET A = I1 - 1
  37. 450 LET T1 = INT(A - fna(A) * 4)
  38. 460 IF T1 = 0 THEN 400
  39. 470 IF B <> 0 THEN 490
  40. 480 LET B = 7
  41. 490 IF (Y1 * 12 + M1) * 31 + D1 < (Y * 12 + M) * 31 + D THEN 550
  42. 500 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 530
  43. 510 PRINT M; "/"; D; "/"; Y; " WAS A ";
  44. 520 GOTO 570
  45. 530 PRINT M; "/"; D; "/"; Y; " IT'S A ";
  46. 540 GOTO 570
  47. 550 PRINT M; "/"; D; "/"; Y; " IT WILL BE A ";
  48. 560 REM PRINT THE DAY OF THE WEEK THE DATE FALLS ON.
  49. 570 IF B <> 1 THEN 590
  50. 580 PRINT "SUNDAY."
  51. 590 IF B <> 2 THEN 610
  52. 600 PRINT "MONDAY."
  53. 610 IF B <> 3 THEN 630
  54. 620 PRINT "TUESDAY."
  55. 630 IF B <> 4 THEN 650
  56. 640 PRINT "WEDNESDAY."
  57. 650 IF B <> 5 THEN 670
  58. 660 PRINT "THURSDAY."
  59. 670 IF B <> 6 THEN 690
  60. 680 GOTO 1250
  61. 690 IF B <> 7 THEN 710
  62. 700 PRINT "SATURDAY."
  63. 710 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 1120
  64. 720 LET I5 = Y1 - Y
  65. 730 PRINT
  66. 740 LET I6 = M1 - M
  67. 750 LET I7 = D1 - D
  68. 760 IF I7 >= 0 THEN 790
  69. 770 LET I6 = I6 - 1
  70. 780 LET I7 = I7 + 30
  71. 790 IF I6 >= 0 THEN 820
  72. 800 LET I5 = I5 - 1
  73. 810 LET I6 = I6 + 12
  74. 820 IF I5 < 0 THEN 1310
  75. 830 IF I7 <> 0 THEN 850
  76. 835 IF I6 <> 0 THEN 850
  77. 840 PRINT "***HAPPY BIRTHDAY***"
  78. 850 PRINT " ", " ", "ANNI", "MESI", "GIORNI"
  79. 855 PRINT " ", " ", "-----", "------", "----"
  80. 860 PRINT "LA TUA ETA      ", I5, I6, I7
  81. 870 LET A8 = (I5 * 365) + (I6 * 30) + I7 + INT(I6 / 2)
  82. 880 LET K5 = I5
  83. 890 LET K6 = I6
  84. 900 LET K7 = I7
  85. 910 REM CALCULATE RETIREMENT DATE.
  86. 920 LET E = Y + 65
  87. 930 REM CALCULATE TIME SPENT IN THE FOLLOWING FUNCTIONS.
  88. 940 LET F = .35
  89. 950 PRINT "HAI DORMITO     ",
  90. 960 GOSUB 1370
  91. 970 LET F = .17
  92. 980 PRINT "TU HAI MANGIATO ",
  93. 990 GOSUB 1370
  94. 1000 LET F = .23
  95. 1010 IF K5 > 3 THEN 1040
  96. 1020 PRINT "HAI GIOCATO",
  97. 1030 GOTO 1080
  98. 1040 IF K5 > 9 THEN 1070
  99. 1050 PRINT "HAI GIOCATO / STUDIATO",
  100. 1060 GOTO 1080
  101. 1070 PRINT "HAI LAVORATO / GIOCATO",
  102. 1080 GOSUB 1370
  103. 1085 GOTO 1530
  104. 1090 PRINT "TI SEI RILASSATO ", K5, K6, K7
  105. 1100 PRINT
  106. 1110 PRINT TAB(16); "***  PUOI ANDARE IN PENSIONE"; E; " ***"
  107. 1120 PRINT
  108. 1140 PRINT
  109. 1200 PRINT
  110. 1210 PRINT
  111. 1220 PRINT
  112. 1230 PRINT
  113. 1240 END
  114. 1250 IF D = 13 THEN 1280
  115. 1260 PRINT "FRIDAY."
  116. 1270 GOTO 710
  117. 1280 PRINT "FRIDAY THE 13TH -- ATTENTION!"
  118. 1290 GOTO 710
  119. 1300 PRINT "NON PREPARATI A DARE GIORNO DELLA SETTIMANA PRIMA DI MDLXXXII. "
  120. 1310 GOTO 1140
  121. 1320 REM TABLE OF VALUES FOR THE MONTHS TO BE USED IN CALCULATIONS.
  122. 1330 DATA 0,3,3,6,1,4,6,2,5,0,3,5
  123. 1340 REM THIS IS THE CURRENT DATE USED IN THE CALCULATIONS.
  124. 1350 REM THIS IS THE DATE TO BE CALCULATED ON.
  125. 1360 REM CALCULATE TIME IN YEARS, MONTHS, AND DAYS
  126. 1370 LET K1 = INT(F * A8)
  127. 1380 LET I5 = INT(K1 / 365)
  128. 1390 LET K1 = K1 - (I5 * 365)
  129. 1400 LET I6 = INT(K1 / 30)
  130. 1410 LET I7 = K1 - (I6 * 30)
  131. 1420 LET K5 = K5 - I5
  132. 1430 LET K6 = K6 - I6
  133. 1440 LET K7 = K7 - I7
  134. 1450 IF K7 >= 0 THEN 1480
  135. 1460 LET K7 = K7 + 30
  136. 1470 LET K6 = K6 - 1
  137. 1480 IF K6 > 0 THEN 1510
  138. 1490 LET K6 = K6 + 12
  139. 1500 LET K5 = K5 - 1
  140. 1510 PRINT I5, I6, I7
  141. 1520 RETURN
  142. 1530 IF K6 = 12 THEN 1550
  143. 1540 GOTO 1090
  144. 1550 LET K5 = K5 + 1
  145. 1560 LET K6 = 0
  146. 1570 GOTO 1090
  147. 1580 REM
  148. 1590 END
  149. FUNCTION fna (A)
  150.     fna = INT(A / 4)
  151. FUNCTION fnb (A)
  152.     fnb = INT(A / 7)
  153.  
« Last Edit: January 05, 2021, 04:39:20 am by Adrian »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #10 on: January 05, 2021, 05:42:16 am »
Aye, that code isn't worth trying to figure out.  The only purpose such code serves is
to show a person how NOT to program.  To "learn" from that code is like learning all
about toaster ovens when one wants to learn how to fix a car.  Study the code on
these forums.  It's all far better stuff.

Do look up the LET command in the Wiki here.  It's hilarious.  And true.

« Last Edit: January 05, 2021, 05:44:24 am by Richard Frost »
It works better if you plug it in.

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #11 on: January 05, 2021, 10:17:04 am »
my favourite gwbasic-style line of code is this:

Code: QB64: [Select]
  1. 1 IF 1 THEN 1
  2.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #12 on: January 05, 2021, 11:57:24 am »
I was correct the 2 define functions were different and Adrian has the difference exactly:
Code: QB64: [Select]
  1. 10 PRINT TAB(32); "WEEKDAY"
  2. 20 PRINT TAB(15); "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  3. 100 PRINT "WEEKDAY IS A COMPUTER DEMONSTRATION THAT"
  4. 110 PRINT "GIVES FACTS ABOUT A DATE OF INTEREST TO YOU."
  5. 120 PRINT
  6. 130 PRINT "ENTER TODAY'S DATE IN THE FORM: 3,24,1979  ";
  7. 140 INPUT M1, D1, Y1
  8. 150 REM THIS PROGRAM DETERMINES THE DAY OF THE WEEK
  9. 160 REM  FOR A DATE AFTER 1582
  10. 170 DEF FNA(A)=INT(A/4)
  11. 180 DIM T(12)
  12. 190 DEF FNB(A)=INT(A/7)
  13. 200 REM SPACE OUTPUT AND READ IN INITIAL VALUES FOR MONTHS.
  14. 210 FOR I= 1 TO 12
  15. 220 READ T(I)
  16. 230 NEXT I
  17. 240 PRINT"ENTER DAY OF BIRTH (OR OTHER DAY OF INTEREST)";
  18. 250 INPUT M,D,Y
  19. 260 PRINT
  20. 270 LET I1 = INT((Y-1500)/100)
  21. 280 REM TEST FOR DATE BEFORE CURRENT CALENDAR.
  22. 290 IF Y-1582 <0 THEN 1300
  23. 300 LET A = I1*5+(I1+3)/4
  24. 310 LET I2=INT(A-FNB(A)*7)
  25. 320 LET Y2=INT(Y/100)
  26. 330 LET Y3 =INT(Y-Y2*100)
  27. 340 LET A =Y3/4+Y3+D+T(M)+I2
  28. 350 LET B=INT(A-FNB(A)*7)+1
  29. 360 IF M > 2 THEN 470
  30. 370 IF Y3 = 0 THEN 440
  31. 380 LET T1=INT(Y-FNA(Y)*4)
  32. 390 IF T1 <> 0 THEN 470
  33. 400 IF B<>0 THEN 420
  34. 410 LET B=6
  35. 420 LET B = B-1
  36. 430 GOTO 470
  37. 440 LET A = I1-1
  38. 450 LET T1=INT(A-FNA(A)*4)
  39. 460 IF T1 = 0 THEN 400
  40. 470 IF B <>0 THEN 490
  41. 480 LET B = 7
  42. 490 IF (Y1*12+M1)*31+D1<(Y*12+M)*31+D THEN 550
  43. 500 IF (Y1*12+M1)*31+D1=(Y*12+M)*31+D THEN 530
  44. 510 PRINT M;"/";D;"/";Y;" WAS A ";
  45. 520 GOTO 570
  46. 530 PRINT M;"/";D;"/";Y;" IS A ";
  47. 540 GOTO 570
  48. 550 PRINT M;"/";D;"/";Y;" WILL BE A ";
  49. 560 REM PRINT THE DAY OF THE WEEK THE DATE FALLS ON.
  50. 570 IF B <>1 THEN 590
  51. 580 PRINT "SUNDAY."
  52. 590 IF B<>2 THEN 610
  53. 600 PRINT "MONDAY."
  54. 610 IF B<>3 THEN 630
  55. 620 PRINT "TUESDAY."
  56. 630 IF B<>4 THEN 650
  57. 640 PRINT "WEDNESDAY."
  58. 650 IF B<>5 THEN 670
  59. 660 PRINT "THURSDAY."
  60. 670 IF B<>6 THEN 690
  61. 680 GOTO 1250
  62. 690 IF B<>7 THEN 710
  63. 700 PRINT "SATURDAY."
  64. 710 IF (Y1*12+M1)*31+D1=(Y*12+M)*31+D THEN 1120
  65. 720 LET I5=Y1-Y
  66. 730 PRINT
  67. 740 LET I6=M1-M
  68. 750 LET I7=D1-D
  69. 760 IF I7>=0 THEN 790
  70. 770 LET I6= I6-1
  71. 780 LET I7=I7+30
  72. 790 IF I6>=0 THEN 820
  73. 800 LET I5=I5-1
  74. 810 LET I6=I6+12
  75. 820 IF I5<0 THEN 1310
  76. 830 IF I7 <> 0 THEN 850
  77. 835 IF I6 <> 0 THEN 850
  78. 840 PRINT"***HAPPY BIRTHDAY***"
  79. 850 PRINT " "," ","YEARS","MONTHS","DAYS"
  80. 855 PRINT " "," ","-----","------","----"
  81. 860 PRINT "YOUR AGE (IF BIRTHDATE) ",I5,I6,I7
  82. 870 LET A8 = (I5*365)+(I6*30)+I7+INT(I6/2)
  83. 880 LET K5 = I5
  84. 890 LET K6 = I6
  85. 900 LET K7 = I7
  86. 910 REM CALCULATE RETIREMENT DATE.
  87. 920 LET E = Y+65
  88. 930 REM CALCULATE TIME SPENT IN THE FOLLOWING FUNCTIONS.
  89. 940 LET F = .35
  90. 950 PRINT "YOU HAVE SLEPT ",
  91. 960 GOSUB 1370
  92. 970 LET F = .17
  93. 980 PRINT "YOU HAVE EATEN ",
  94. 990 GOSUB 1370
  95. 1000 LET F = .23
  96. 1010 IF K5 > 3 THEN 1040
  97. 1020 PRINT "YOU HAVE PLAYED",
  98. 1030 GOTO 1080
  99. 1040 IF K5 > 9 THEN 1070
  100. 1050 PRINT "YOU HAVE PLAYED/STUDIED",
  101. 1060 GOTO  1080
  102. 1070 PRINT "YOU HAVE WORKED/PLAYED",
  103. 1080 GOSUB 1370
  104. 1085 GOTO 1530
  105. 1090 PRINT "YOU HAVE RELAXED ",K5,K6,K7
  106. 1100 PRINT
  107. 1110 PRINT TAB(16);"***  YOU MAY RETIRE IN";E;" ***"
  108. 1120 PRINT
  109. 1140 PRINT
  110. 1200 PRINT
  111. 1210 PRINT
  112. 1220 PRINT
  113. 1230 PRINT
  114. 1240 END
  115. 1250 IF D=13 THEN 1280
  116. 1260 PRINT "FRIDAY."
  117. 1270 GOTO 710
  118. 1280 PRINT "FRIDAY THE THIRTEENTH---BEWARE!"
  119. 1290 GOTO 710
  120. 1300 PRINT "NOT PREPARED TO GIVE DAY OF WEEK PRIOR TO MDLXXXII. "
  121. 1310 GOTO 1140
  122. 1320 REM TABLE OF VALUES FOR THE MONTHS TO BE USED IN CALCULATIONS.
  123. 1330 DATA 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5
  124. 1340 REM THIS IS THE CURRENT DATE USED IN THE CALCULATIONS.
  125. 1350 REM THIS IS THE DATE TO BE CALCULATED ON.
  126. 1360 REM CALCULATE TIME IN YEARS, MONTHS, AND DAYS
  127. 1370 LET K1=INT(F*A8)
  128. 1380 LET I5 = INT(K1/365)
  129. 1390 LET K1 = K1- (I5*365)
  130. 1400 LET I6 = INT(K1/30)
  131. 1410 LET I7 = K1 -(I6*30)
  132. 1420 LET K5 = K5-I5
  133. 1430 LET K6 =K6-I6
  134. 1440 LET K7 = K7-I7
  135. 1450 IF K7>=0 THEN 1480
  136. 1460 LET K7=K7+30
  137. 1470 LET K6=K6-1
  138. 1480 IF K6>0 THEN 1510
  139. 1490 LET K6=K6+12
  140. 1500 LET K5=K5-1
  141. 1510 PRINT I5,I6,I7
  142. 1520 RETURN
  143. 1530 IF K6=12 THEN 1550
  144. 1540 GOTO 1090
  145. 1550 LET K5=K5+1
  146. 1560 LET K6=0
  147. 1570 GOTO 1090
  148. 1580 REM
  149. 1590 END
  150.  

This was from Kiara's post of Dec 24,  ...\HPSource\Basic_source_code\BCG  weekday.bas, line 190 was supposed to be:
Code: QB64: [Select]
  1. 190 DEF FNB(A)=INT(A/7)
  2.  
line 170 was properly translated to the other function.
« Last Edit: January 05, 2021, 12:01:26 pm by bplus »

Offline Kiara87

  • Forum Regular
  • Posts: 164
    • View Profile
Re: gwbasic's if statement doesn't work on qb64
« Reply #13 on: January 05, 2021, 03:31:25 pm »
thank you all for replying
the problem was as adrian and bplus says
here was the reason that I don't notice the day of variable b
FUNCTION fnb (A)
    fnb = INT(A / 7)
END FUNCTION


Code: QB64: [Select]
  1. 10 PRINT TAB(32); "WEEKDAY"
  2. 20 PRINT TAB(15); "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  3. 100 PRINT "WEEKDAY IS A COMPUTER DEMONSTRATION THAT"
  4. 110 PRINT "DA FATTI SU UNA DATA DI INTERESSE PER VOI."
  5. 120 PRINT
  6. 130 PRINT "INSERISCI LA DATA DI OGGI NEL MODULO: 3,24,1979  ";
  7. 140 INPUT M1, D1, Y1
  8. 150 REM THIS PROGRAM DETERMINES THE DAY OF THE WEEK
  9. 160 REM  FOR A DATE AFTER 1582
  10. 180 DIM T(12)
  11.  
  12. 200 REM SPACE OUTPUT AND READ IN INITIAL VALUES FOR MONTHS.
  13. 210 FOR I = 1 TO 12
  14.    220 READ T(I)
  15. 230 NEXT I
  16. 240 PRINT "INSERISCI GIORNO DI NASCITA (O ALTRO GIORNO DI INTERESSE)";
  17. 250 INPUT M, D, Y
  18. 260 PRINT
  19. 270 LET I1 = INT((Y - 1500) / 100)
  20. 280 REM TEST FOR DATE BEFORE CURRENT CALENDAR.
  21. 290 IF Y - 1582 < 0 THEN 1300
  22. 300 LET A = I1 * 5 + (I1 + 3) / 4
  23. 310 LET I2 = INT(A - fnb(A) * 7)
  24. 320 LET Y2 = INT(Y / 100)
  25. 330 LET Y3 = INT(Y - Y2 * 100)
  26. 340 LET A = Y3 / 4 + Y3 + D + T(M) + I2
  27. 350 LET B = INT(A - fnb(A) * 7) + 1
  28. 360 IF M > 2 THEN 470
  29. 370 IF Y3 = 0 THEN 440
  30. 380 LET T1 = INT(Y - fna(Y) * 4)
  31. 390 IF T1 <> 0 THEN 470
  32. 400 IF B <> 0 THEN 420
  33. 410 LET B = 6
  34. 420 LET B = B - 1
  35. 430 GOTO 470
  36. 440 LET A = I1 - 1
  37. 450 LET T1 = INT(A - fna(A) * 4)
  38. 460 IF T1 = 0 THEN 400
  39. 470 IF B <> 0 THEN 490
  40. 480 LET B = 7
  41. 490 IF (Y1 * 12 + M1) * 31 + D1 < (Y * 12 + M) * 31 + D THEN 550
  42. 500 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 530
  43. 510 PRINT M; "/"; D; "/"; Y; " ERA UN ";
  44. 520 GOTO 570
  45. 530 PRINT M; "/"; D; "/"; Y; " E UN ";
  46. 540 GOTO 570
  47. 550 PRINT M; "/"; D; "/"; Y; " SARA UN ";
  48. 560 REM PRINT THE DAY OF THE WEEK THE DATE FALLS ON.
  49. 570 IF B <> 1 THEN 590
  50. 580 PRINT "DOMENICA."
  51. 590 IF B <> 2 THEN 610
  52. 600 PRINT "LUNEDI."
  53. 610 IF B <> 3 THEN 630
  54. 620 PRINT "MARTEDI."
  55. 630 IF B <> 4 THEN 650
  56. 640 PRINT "MERCOLEDI."
  57. 650 IF B <> 5 THEN 670
  58. 660 PRINT "GIOVEDI."
  59. 670 IF B <> 6 THEN 690
  60. 680 GOTO 1250
  61. 690 IF B <> 7 THEN 710
  62. 700 PRINT "SABATO."
  63. 710 IF (Y1 * 12 + M1) * 31 + D1 = (Y * 12 + M) * 31 + D THEN 1120
  64. 720 LET I5 = Y1 - Y
  65. 730 PRINT
  66. 740 LET I6 = M1 - M
  67. 750 LET I7 = D1 - D
  68. 760 IF I7 >= 0 THEN 790
  69. 770 LET I6 = I6 - 1
  70. 780 LET I7 = I7 + 30
  71. 790 IF I6 >= 0 THEN 820
  72. 800 LET I5 = I5 - 1
  73. 810 LET I6 = I6 + 12
  74. 820 IF I5 < 0 THEN 1310
  75. 830 IF I7 <> 0 THEN 850
  76. 835 IF I6 <> 0 THEN 850
  77. 840 PRINT "***HAPPY BIRTHDAY***"
  78. 850 PRINT " ", " ", "ANNI", "MESI", "GIORNI"
  79. 855 PRINT " ", " ", "-----", "------", "----"
  80. 860 PRINT "LA TUA ETA      ", I5, I6, I7
  81. 870 LET A8 = (I5 * 365) + (I6 * 30) + I7 + INT(I6 / 2)
  82. 880 LET K5 = I5
  83. 890 LET K6 = I6
  84. 900 LET K7 = I7
  85. 910 REM CALCULATE RETIREMENT DATE.
  86. 920 LET E = Y + 65
  87. 930 REM CALCULATE TIME SPENT IN THE FOLLOWING FUNCTIONS.
  88. 940 LET F = .35
  89. 950 PRINT "HAI DORMITO     ",
  90. 960 GOSUB 1370
  91. 970 LET F = .17
  92. 980 PRINT "TU HAI MANGIATO ",
  93. 990 GOSUB 1370
  94. 1000 LET F = .23
  95. 1010 IF K5 > 3 THEN 1040
  96. 1020 PRINT "HAI GIOCATO",
  97. 1030 GOTO 1080
  98. 1040 IF K5 > 9 THEN 1070
  99. 1050 PRINT "HAI GIOCATO / STUDIATO",
  100. 1060 GOTO 1080
  101. 1070 PRINT "HAI LAVORATO / GIOCATO",
  102. 1080 GOSUB 1370
  103. 1085 GOTO 1530
  104. 1090 PRINT "TI SEI RILASSATO ", K5, K6, K7
  105. 1100 PRINT
  106. 1110 PRINT TAB(16); "***  PUOI ANDARE IN PENSIONE"; E; " ***"
  107. 1120 PRINT
  108. 1140 PRINT
  109. 1200 PRINT
  110. 1210 PRINT
  111. 1220 PRINT
  112. 1230 PRINT
  113. 1240 END
  114. 1250 IF D = 13 THEN 1280
  115. 1260 PRINT "VENERDI."
  116. 1270 GOTO 710
  117. 1280 PRINT "VENERDI TREDICESIMO --- ATTENZIONE!"
  118. 1290 GOTO 710
  119. 1300 PRINT "NON PREPARATI A DARE GIORNO DELLA SETTIMANA PRIMA DI MDLXXXII. "
  120. 1310 GOTO 1140
  121. 1320 REM TABLE OF VALUES FOR THE MONTHS TO BE USED IN CALCULATIONS.
  122. 1330 DATA 0,3,3,6,1,4,6,2,5,0,3,5
  123. 1340 REM THIS IS THE CURRENT DATE USED IN THE CALCULATIONS.
  124. 1350 REM THIS IS THE DATE TO BE CALCULATED ON.
  125. 1360 REM CALCULATE TIME IN YEARS, MONTHS, AND DAYS
  126. 1370 LET K1 = INT(F * A8)
  127. 1380 LET I5 = INT(K1 / 365)
  128. 1390 LET K1 = K1 - (I5 * 365)
  129. 1400 LET I6 = INT(K1 / 30)
  130. 1410 LET I7 = K1 - (I6 * 30)
  131. 1420 LET K5 = K5 - I5
  132. 1430 LET K6 = K6 - I6
  133. 1440 LET K7 = K7 - I7
  134. 1450 IF K7 >= 0 THEN 1480
  135. 1460 LET K7 = K7 + 30
  136. 1470 LET K6 = K6 - 1
  137. 1480 IF K6 > 0 THEN 1510
  138. 1490 LET K6 = K6 + 12
  139. 1500 LET K5 = K5 - 1
  140. 1510 PRINT I5, I6, I7
  141. 1520 RETURN
  142. 1530 IF K6 = 12 THEN 1550
  143. 1540 GOTO 1090
  144. 1550 LET K5 = K5 + 1
  145. 1560 LET K6 = 0
  146. 1570 GOTO 1090
  147. 1580 REM
  148. 1590 END
  149. FUNCTION fna (A)
  150.     fna = INT(A / 4)
  151. FUNCTION fnb (A)
  152.     fnb = INT(A / 7)
  153.  
  154.  
  155.  

se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione