# Calorie counter

```[start]

nomainwin

Dim myChoices\$(13)
myChoices\$(0)  = "Augli"
myChoices\$(1)  = "Darzeni"
myChoices\$(2)  = "Gala"
myChoices\$(3)  = "Gatavie"
myChoices\$(4)  = "Maize"
myChoices\$(5)  = "Olas"
myChoices\$(6)  = "Pakstis"
myChoices\$(7)  = "Piens"
myChoices\$(8)  = "Rieksti"
myChoices\$(9)  = "Saldejums"
myChoices\$(10) = "Saldumi"
myChoices\$(12) = "Zivis"
myChoices\$(13) = "Zupas"

WindowWidth  = 800
WindowHeight = 650
UpperLeftX   = 100
UpperLeftY   =   1

statictext #my1.status7,  "Augli",                      15,  50, 115, 40
statictext #my1.status8,  "Darzeni",                    15,  90, 115, 40
statictext #my1.status9,  "Gala un galas edieni",       15, 130, 115, 40
statictext #my1.status10, "Gatavie edieni",             15, 170, 115, 40
statictext #my1.status11, "Maize",                      15, 210, 115, 40
statictext #my1.status12, "Olas",                       15, 250, 115, 40
statictext #my1.status13, "Paksaugi un graudaugi",      15, 290, 115, 40
statictext #my1.status14, "Piena produkti",             15, 330, 115, 40
statictext #my1.status15, "Rieksti un seklas",          15, 370, 115, 40
statictext #my1.status16, "Saldejums",                  15, 410, 115, 40
statictext #my1.status17, "Saldinataji un saldumi",     15, 450, 115, 40
statictext #my1.status18, "siers un senes",             15, 490, 115, 40
statictext #my1.status19, "zivis",                      15, 530, 115, 40
statictext #my1.status20, "zupas",                      15, 570, 115, 40
statictext #my1.status2,  "Products",                   141, 15, 115, 15
statictext #my1.status3,  "Weight (g)",                 290, 15, 115, 15
statictext #my1.status4,  "Calories",                   435, 15, 115, 15
statictext #my1.status5,  "Calories Total",             577, 15, 115, 15
statictext #my1.status6,  "Calories Eaten Before",      577, 90, 115, 15

ComboBox #my1.Augli, Augli\$(), getCalorieCount,         140, 45, 100, 20
Dim Augli\$(12) : Dim AugliCalories(12)
Augli\$(0) = "aboli" :               AugliCalories(0)  =  52
Augli\$(1) = "ananasi" :             AugliCalories(1)  =  48
Augli\$(2) = "apelsini" :            AugliCalories(2)  =  39
Augli\$(3) = "aprikozes" :           AugliCalories(3)  =  41
Augli\$(4) = "arbuzi" :              AugliCalories(4)  =  46
Augli\$(5) = "banani" :              AugliCalories(5)  =  89
Augli\$(6) = "bumbieri" :            AugliCalories(6)  =  43
Augli\$(7) = "greipfruts" :          AugliCalories(7)  =  32
Augli\$(8) = "kivi" :                AugliCalories(8)  =  52
Augli\$(9) = "mandarini" :           AugliCalories(9)  =  37
Augli\$(10) = "rozines" :            AugliCalories(10) = 299
Augli\$(11) = "vinogas" :            AugliCalories(11) =  69
Augli\$(12) = "zavetas aprikozes" :  AugliCalories(12) = 260

combobox #my1.Darzeni, Darzeni\$(), getCalorieCount, 140, 85, 100, 30
Dim Darzeni\$(17) : Dim DarzeniCalories(17)
Darzeni\$(0) = "bietes" :            DarzeniCalories(0)  =  43
Darzeni\$(1) = "brokoli" :           DarzeniCalories(1)  =  28
Darzeni\$(2) = "burkani" :           DarzeniCalories(2)  =  38
Darzeni\$(3) = "dilles" :            DarzeniCalories(3)  =  29
Darzeni\$(4) = "galvinkaposti" :     DarzeniCalories(4)  =  21
Darzeni\$(5) = "gurki" :             DarzeniCalories(5)  =  15
Darzeni\$(6) = "kaposti" :           DarzeniCalories(6)  =  13
Darzeni\$(7) = "kartupeli" :         DarzeniCalories(7)  =  76
Darzeni\$(8) = "kiploki" :           DarzeniCalories(8)  =  51
Darzeni\$(9) = "olivas" :            DarzeniCalories(9)  = 350
Darzeni\$(10) = "paprika sarkana" :  DarzeniCalories(10) =  26
Darzeni\$(11) = "paprika zala" :     DarzeniCalories(11) =  41
Darzeni\$(12) = "pukkaposti" :       DarzeniCalories(12) =  23
Darzeni\$(13) = "puravi" :           DarzeniCalories(13) =  25
Darzeni\$(14) = "redisi" :           DarzeniCalories(14) =  18
Darzeni\$(15) = "sipoli" :           DarzeniCalories(15) =  42
Darzeni\$(16) = "skabeti kaposti" :  DarzeniCalories(16) =  22
Darzeni\$(17) = "zalie zirnisi" :    DarzeniCalories(17) =  81

combobox #my1.Gala, Gala\$(), getCalorieCount, 140, 125, 100, 30
Dim Gala\$(12) : Dim GalaCalories(12)
Gala\$(0) = "cepta vista" :          GalaCalories(0)  = 300
Gala\$(1) = "cisini Rakveres" :      GalaCalories(1)  = 222
Gala\$(2) = "cukgala" :              GalaCalories(2)  = 372
Gala\$(3) = "Doktora desa Nakotne" : GalaCalories(3)  = 135
Gala\$(4) = "liellopa gala" :        GalaCalories(4)  = 213
Gala\$(5) = "liellopa malta gala" :  GalaCalories(5)  = 170
Gala\$(6) = "salami" :               GalaCalories(6)  = 407
Gala\$(7) = "sardeles" :             GalaCalories(7)  = 329
Gala\$(8) = "skinkis" :              GalaCalories(8)  = 290
Gala\$(9) = "Doktora desa RGK" :     GalaCalories(9)  = 189
Gala\$(10) = "vistas balta gala" :   GalaCalories(10) = 111
Gala\$(11) = "vistas sparnini" :     GalaCalories(11) = 120
Gala\$(12) = "zaveta desa" :         GalaCalories(12) = 510

combobox #my1.Gatavie, Gatavie\$(), getCalorieCount, 140, 165, 100, 30
Gatavie\$(0) = "burkanu-zirnisu sautejums" : GatavieCalories(0) =  83
Gatavie\$(1) = "darzenu sautejums" :         GatavieCalories(1) = 114
Gatavie\$(2) = "kartupelu biezputra" :       GatavieCalories(2) =  83
Gatavie\$(3) = "kartupelu pankukas" :        GatavieCalories(3) = 181
Gatavie\$(4) = "makaroni ar sieru" :         GatavieCalories(4) = 210
Gatavie\$(5) = "planas pankukas" :           GatavieCalories(5) = 229

combobox #my1.Maize, Maize\$(), getCalorieCount, 140, 205, 100, 30
Maize\$(0) = "Raganas sladskabbmaize" :      MaizeCalories(0) =  52
Maize\$(1) = "Vita tostermaize" :            MaizeCalories(1) = 265

combobox #my1.Olas, Olas\$(), getCalorieCount, 140, 245, 100, 30
Olas\$(0) = "cepta ola" :                OlasCalories(0) = 201
Olas\$(1) = "omlete" :                   OlasCalories(1) = 153
Olas\$(2) = "varita ola" :               OlasCalories(2) = 155

combobox #my1.Pakstis, Pakstis\$(), getCalorieCount, 140, 285, 100, 30
Pakstis\$(0) = "auzas atri varamas" :    PakstisCalories(0) = 368
Pakstis\$(1) = "baltas pupinas" :        PakstisCalories(1) = 304
Pakstis\$(2) = "griki Maxima" :          PakstisCalories(2) = 349
Pakstis\$(3) = "konservetas pupinas" :   PakstisCalories(3) = 105
Pakstis\$(4) = "makaroni Maxima" :       PakstisCalories(4) = 220
Pakstis\$(5) = "melnas pupas" :          PakstisCalories(5) = 292
Pakstis\$(6) = "risi" :                  PakstisCalories(6) = 342
Pakstis\$(7) = "brunie risi" :           PakstisCalories(7) = 337
Pakstis\$(8) = "zirni" :                 PakstisCalories(8) = 291

combobox #my1.Piens, Piens\$(), getCalorieCount, 140, 325, 100, 30
Piens\$(0) = "biezpiens Jaunpils" :      PiensCalories(0) = 88
Piens\$(1) = "Karums" :                  PiensCalories(1) = 340
Piens\$(2) = "kefirs" :                  PiensCalories(2) = 49
Piens\$(3) = "piens" :                   PiensCalories(3) = 48
Piens\$(4) = "krejums saldais" :         PiensCalories(4) = 345
Piens\$(5) = "krejums skabais" :         PiensCalories(5) = 251

combobox #my1.Rieksti, Rieksti\$(), getCalorieCount, 140, 365, 100, 30
Rieksti\$(0) = "lazdu rieksti" :         RiekstiCalories(0) = 628
Rieksti\$(1) = "mandeles" :              RiekstiCalories(1) = 653
Rieksti\$(2) = "pistacijas" :            RiekstiCalories(2) = 670
Rieksti\$(3) = "valrieksti" :            RiekstiCalories(3) = 654
Rieksti\$(4) = "zemesrieksti" :          RiekstiCalories(4) = 567

combobox #my1.Saldejums, Saldejums\$(), getCalorieCount, 140, 405, 100, 30
Saldejums\$(0) = "sokolades" :           SaldejumsCalories(0) = 140
Saldejums\$(1) = "vanilas" :             SaldejumsCalories(1) = 140

combobox #my1.Saldumi, Saldumi\$(), getCalorieCount, 140, 445, 100, 30
Saldumi\$(0) = "cukurs" :                SaldumiCalories(0) = 402
Saldumi\$(1) = "medus" :                 SaldumiCalories(1) = 314
Saldumi\$(2) = "auzu cepumi" :           SaldumiCalories(2) = 401
Saldumi\$(3) = "ievarijums" :            SaldumiCalories(3) = 278
Saldumi\$(4) = "Snickers" :              SaldumiCalories(4) = 479
Saldumi\$(5) = "melna sokolade" :        SaldumiCalories(5) = 545
Saldumi\$(6) = "piena sokolade" :        SaldumiCalories(6) = 492
Saldumi\$(7) = "Twiks" :                 SaldumiCalories(7) = 499

combobox #my1.Zivis, Zivis\$(), getCalorieCount, 140, 525, 100, 30
Zivis\$(0) = "lasis" :               ZivisCalories(0) = 196
Zivis\$(1) = "lidaka" :              ZivisCalories(1) =  81
Zivis\$(2) = "tuncis" :              ZivisCalories(2) = 113
Zivis\$(3) = "silke" :               ZivisCalories(3) = 180

combobox #my1.Zupas, Zupas\$(), getCalorieCount, 140, 565, 100, 30
Zupas\$(0) = "senu zupa" :           ZupasCalories(0) = 52
Zupas\$(1) = "pupinu zupa" :         ZupasCalories(1) = 91
Zupas\$(2) = "zirnu zupa" :          ZupasCalories(2) = 78

textbox #my1.txtAugliAmount,        290,  45, 100, 24
textbox #my1.txtDarzeniAmount,      290,  85, 100, 24
textbox #my1.txtGalaAmount,         290, 125, 100, 24
textbox #my1.txtGatavieAmount,      290, 165, 100, 24
textbox #my1.txtMaizeAmount,        290, 205, 100, 24
textbox #my1.txtOlasAmount,         290, 245, 100, 24
textbox #my1.txtPakstisAmount,      290, 285, 100, 24
textbox #my1.txtPiensAmount,        290, 325, 100, 24
textbox #my1.txtRiekstiAmount,      290, 365, 100, 24
textbox #my1.txtSaldejumsAmount,    290, 405, 100, 24
textbox #my1.txtSaldumiAmount,      290, 445, 100, 24
textbox #my1.txtSierssenesAmount,   290, 485, 100, 24
textbox #my1.txtZivisAmount,        290, 525, 100, 24
textbox #my1.txtZupasAmount,        290, 565, 100, 24
textbox #my1.txtAugliCalories,      435,  45, 100, 24
textbox #my1.txtDarzeniCalories,    435,  85, 100, 24
textbox #my1.txtGalaCalories,       435, 125, 100, 24
textbox #my1.txtGatavieCalories,    435, 165, 100, 24
textbox #my1.txtMaizeCalories,      435, 205, 100, 24
textbox #my1.txtOlasCalories,       435, 245, 100, 24
textbox #my1.txtPakstisCalories,    435, 285, 100, 24
textbox #my1.txtPiensCalories,      435, 325, 100, 24
textbox #my1.txtRiekstiCalories,    435, 365, 100, 24
textbox #my1.txtSaldejumsCalories,  435, 405, 100, 24
textbox #my1.txtSaldumiCalories,    435, 445, 100, 24
textbox #my1.txtSierssenesCalories, 435, 485, 100, 24
textbox #my1.txtZivisCalories,      435, 525, 100, 24
textbox #my1.txtZupasCalories,      435, 565, 100, 24
textbox #my1.kalkopa,               575,  45, 100, 24
textbox #my1.kalatl,                575, 125, 100, 24

button #my1.ok,    "OK!",   getCalorieCount, UL, 670, 460, 75, 50
button #my1.quit,  "Quit!", btnQuit,         UL, 670, 530, 75, 50
button #my1.reset, "Reset", [reset],         UL, 670, 390, 75, 50

open "Kalorijas" for window as #my1

#my1 "TrapClose Quit"

print #my1.status2,  "!Font Times_New_Roman 10 Bold"
print #my1.status3,  "!Font Times_New_Roman 10 Bold"
print #my1.status4,  "!Font Times_New_Roman 10 Bold"
print #my1.status5,  "!Font Times_New_Roman 10 Bold"
print #my1.status6,  "!Font Times_New_Roman 10 Bold"
print #my1.status7,  "!Font Times_New_Roman 10"
print #my1.status8,  "!Font Times_New_Roman 10"
print #my1.status9,  "!Font Times_New_Roman 10"
print #my1.status10, "!Font Times_New_Roman 10"
print #my1.status11, "!Font Times_New_Roman 10"
print #my1.status12, "!Font Times_New_Roman 10"
print #my1.status13, "!Font Times_New_Roman 10"
print #my1.status14, "!Font Times_New_Roman 10"
print #my1.status15, "!Font Times_New_Roman 10"
print #my1.status16, "!Font Times_New_Roman 10"
print #my1.status17, "!Font Times_New_Roman 10"
print #my1.status18, "!Font Times_New_Roman 10"
print #my1.status19, "!Font Times_New_Roman 10"
print #my1.status20, "!Font Times_New_Roman 10"

open "myfile.txt" for input as #1
INPUT #1, num1\$
close #1

num1 =val( num1\$)

#my1.kalatl num1

wait    '   __________________________________________________________________________________-

Sub getCalorieCount handle\$
For i = 0 To 13
amount\$ = "0" : index = -1
amountHandle\$   = "#my1.txt"; myChoices\$(i); "Amount"
comboBoxHandle\$ = "#my1.";    myChoices\$(i)
calorieHandle\$  = "#my1.txt"; myChoices\$(i); "Calories"
#amountHandle\$ "!Contents? amount\$"

If Val( amount\$) > 0 Then
#comboBoxHandle\$ "SelectionIndex? index"
calories\$ = str\$( (Val( amount\$) / 100) * Val( Eval\$( myChoices\$( i); "Calories("; str\$( index - 1); ")")))
#calorieHandle\$ calories\$
totalCalories = totalCalories + Val( calories\$)
End If
Next i

#my1.kalkopa str\$( totalCalories)

open "myfile.txt" for output as #myHandle 'save calories
print #myHandle, str\$( totalCalories)
close #myHandle

End Sub '   ___________________________________________________________________

Sub btnQuit handle\$
Call Quit "#my1"
End Sub

Sub Quit handle\$
Close #handle\$
End
End Sub    '   _______________________________________________________________

'This part of program doesn't work and I don't know why!
valueC = num1 +totalCalories 'to get amount of calories selected now and saved in previous session

[reset]
open "myfile.txt" for output as #myHandle 'reset calories-saved and current-calories-total to zero
print #myHandle, 0
close #myHandle

close #my1
goto [start]
```