home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Set of Apple II Hard Drive Images
/
eric.hdv
/
DIET2
/
DIARY.BAS
< prev
next >
Wrap
BASIC Source File
|
2020-08-13
|
5KB
|
130 lines
1 DIM FC$(500),FD$(500),PO$(500),CA(500),FC(500),FA(500),SF(500),CH(500),SO(500),CB(500),FI(500),SU(500),PR(500)
2 VH = 20
5 D$ = CHR$(4)
7 F$ = "FOODLIST.TXT"
8 PRINT "READING FOOD LIST..."
10 PRINT D$"OPEN "F$
20 PRINT D$"READ "F$
90 I = 1
100 ONERR GOTO 150
110 INPUT FC$(I),FD$(I),PO$(I),CA(I),FC(I),FA(I),SF(I),CH(I),SO(I),CB(I),FI(I),SU(I),PR(I)
115 I = I +1
120 GOTO 110
150 POKE 216,0: PRINT D$"CLOSE"F$
155 MX = I -1
160 PRINT MX;" FOODS ON FILE.": PRINT
165 PRINT "*** FOOD DIARY ***": PRINT
168 PRINT D$"OPEN TODAY.TXT": PRINT D$"READ TODAY.TXT": INPUT YY,MM,DD: PRINT D$"CLOSE TODAY.TXT": GOTO 190
169 REM *** 170-189 ARE DEAD CODE ***
170 INPUT "WHAT YEAR IS IT?";YY
172 IF YY <1998 THEN PRINT "INVALID YEAR": GOTO 170
175 INPUT "WHAT MONTH IS IT?";MM
177 IF MM <1 OR MM >12 THEN PRINT "INVALID MONTH": GOTO 175
180 INPUT "WHAT DAY IS IT?";DD
182 IF DD <1 OR DD >31 THEN PRINT "INVALID DAY": GOTO 180
190 O$ = "D." + STR$(YY) +"." + STR$(MM) +"." + STR$(DD)
192 PRINT "OPENING FILE: "O$
193 PRINT
194 PRINT D$"OPEN "O$
195 PRINT D$"READ "O$
200 ONERR GOTO 245
210 INPUT FC$,PO,CA,FC,FA,SF,CH,SO,CB,FI,SU,PR,PO$,FD$
215 PRINT PO" X "PO$" "FD$
230 CA(0) = CA(0) +CA
231 FC(0) = FC(0) +FC
232 FA(0) = FA(0) +FA
233 SF(0) = SF(0) +SF
234 CH(0) = CH(0) +CH
235 SO(0) = SO(0) +SO
236 CB(0) = CB(0) +CB
237 FI(0) = FI(0) +FI
238 SU(0) = SU(0) +SU
239 PR(0) = PR(0) +PR
240 GOTO 210
245 POKE 216,0: PRINT
246 IF CA(0) = 0 THEN 248
247 PRINT "SO FAR, THAT'S "CA(0)" CALORIES (" INT(FC(0)/CA(0) *100)"% FAT)"
248 PRINT CHR$(7); CHR$(7): INPUT "PRESS RETURN TO CONTINUE.";R$
250 HOME : PRINT "HERE IS YOUR MENU:"
255 PRINT "---------------------------------------"
257 FOR I = 1 TO MX
260 PRINT FC$(I); SPC( 8 - LEN(FC$(I)));":"FD$(I)
270 IF I/VH = INT(I/VH) AND I >0 THEN INPUT "MORE (Y/N):";MO$: IF LEFT$(MO$,1) < >"Y" THEN I = MX
300 NEXT I
310 PRINT "---------------------------------------"
390 PRINT "(TYPE 'MENU' TO RE-DISPLAY ABOVE MENU)"
391 PRINT "(TYPE 'ADD' TO ADD FOODS TO THE MENU)"
392 PRINT "(TYPE 'STATS' TO SEE YOUR TOTALS)"
395 PRINT "(TYPE 'DONE' WHEN YOU'RE DONE EATING)"
399 PRINT
400 INPUT "SO, WHAT DID YOU EAT TODAY? :";FO$
403 IF FO$ = "STATS" THEN HOME : GOSUB 510: INPUT "PRESS RETURN TO CONTINUE:";RE$: GOTO 310
405 IF FO$ = "MENU" THEN 250
406 IF FO$ = "ADD" THEN PRINT : PRINT D$"CLOSE": PRINT D$"RUN ADDFOOD.BAS": END
407 IF FO$ = "DONE" THEN 500
410 GOSUB 1000
412 IF FD = 0 THEN PRINT "THAT CODE IS NOT ON FILE- TRY AGAIN.": GOTO 400
415 PRINT
420 PRINT PO$(IX);" ";FD$(IX): PRINT
430 INPUT "AND HOW MANY PORTIONS OF IT?:";PO
440 PRINT
450 PRINT "LET'S SEE..."
460 PRINT CA(IX) *PO" CALORIES ("FC(IX) *PO" FROM FAT)"
465 PRINT FA(IX) *PO" G FAT, "SF(IX) *PO" G SATURATED FAT"
470 PRINT CH(IX) *PO" MG CHOLESTEROL, "SO(IX) *PO" MG SODIUM"
475 PRINT CB(IX) *PO" G CARB. ("FI(IX) *PO" FIBER, "SU(IX) *PO" SUGARS)"
480 PRINT "AND "PR(IX) *PO" G PROTEIN."
485 GOSUB 2000
487 PRINT
490 INPUT "OK, WHAT ELSE DID YOU EAT? :";FO$
495 GOTO 405
500 HOME : GOTO 800
510 PRINT "TODAY'S TOTALS"
520 PRINT "--------------"
530 PRINT "CALORIES: ",CA(0)
539 IF CA(0) = 0 THEN 550
540 PRINT "FAT CALORIES:",FC(0);" ("; INT(FC(0)/CA(0) *100)" %)"
550 PRINT "TOTAL FAT: ",FA(0)" G"
560 PRINT "SATURATED FAT:",SF(0)" G"
570 PRINT "CHOLESTEROL: ",CH(0)" MG"
580 PRINT "SODIUM: ",SO(0)" MG"
590 PRINT "CARBOHYDRATES:",CB(0)" G"
600 PRINT "DIETARY FIBER:",FI(0)" G"
610 PRINT "SUGARS: ",SU(0)" G"
620 PRINT "PROTEIN: ",PR(0)" G"
700 PRINT : PRINT "FDA RECOMMENDATIONS:"
710 PRINT " 2000 CAL 2500 CAL": PRINT "--------------------------------"
720 PRINT "TOT FAT < 65 G < 80 G"
730 PRINT "SAT FAT < 20 G < 25 G"
740 PRINT "CHOLEST < 300 MG < 300 MG"
750 PRINT "SODIUM < 2400 MG < 2400 MG"
760 PRINT "TOT CARB 300 G 375 G"
770 PRINT "FIBER 25 G 30 G"
780 RETURN
800 PRINT D$"CLOSE"
805 GOSUB 510
810 RP$ = "T." + STR$(YY) +"." + STR$(MM) +"." + STR$(DD)
820 PRINT D$"OPEN "RP$: PRINT D$"WRITE "RP$
830 GOSUB 510
840 PRINT : PRINT
990 PRINT D$"CLOSE"RP$
999 END
1000 FD = 0
1010 FOR I = 1 TO MX
1020 IF FO$ = FC$(I) THEN IX = I:I = MX:FD = 1
1030 NEXT I
1040 RETURN
2000 PRINT CHR$(4)"APPEND "O$: PRINT CHR$(4)"WRITE "O$
2010 PRINT FC$(IX)","PO","CA(IX) *PO","FC(IX) *PO","FA(IX) *PO","SF(IX) *PO","CH(IX) *PO","SO(IX) *PO","CB(IX) *PO","FI(IX) *PO","SU(IX) *PO","PR(IX) *PO","PO$(IX)","FD$(IX)
2020 PRINT D$
2100 CA(0) = CA(0) +CA(IX) *PO
2110 FC(0) = FC(0) +FC(IX) *PO
2120 FA(0) = FA(0) +FA(IX) *PO
2130 SF(0) = SF(0) +SF(IX) *PO
2140 CH(0) = CH(0) +CH(IX) *PO
2150 SO(0) = SO(0) +SO(IX) *PO
2160 CB(0) = CB(0) +CB(IX) *PO
2170 FI(0) = FI(0) +FI(IX) *PO
2180 SU(0) = SU(0) +SU(IX) *PO
2190 PR(0) = PR(0) +PR(IX) *PO
2200 RETURN