|
Post by jarychk on Jul 8, 2024 6:41:26 GMT
I formed nearly all the parts to a newest program using Just BASIC: Bean quantity and number of servings calculator It would at best appeal to almost nobody, as a useful application; maybe very few may be interested and like what it does.
Mostly finished as the *.bas file, but some minor faults to check and some in-program documentation to check and finish; and maybe a need to package the application
Sharing the program?
Sharing could be done here, as giving the program code in a post, so JB people could check and find their impressions. Not sure if to call the program as "open source" or not, but if posted here, JB people are able to do what they want to it...
GitHub? Is that a way to share the program? Too difficult to understand, for me and not sure if that is appropriate. Maybe it would not belong there.
Just BASIC Files Archive - is that still a good idea? Still a site of much activity and value?
Upload the *bas file OR a workable zipped package to Google Drive account - maybe a workable way so interested people could download and try the program
Maybe simplest and easiest is, just I post the code on J B Forum/Proboards.
|
|
|
Post by plus on Jul 8, 2024 12:23:07 GMT
take the simplest and easiest for sure! If you want to share code this is perfect place for beginners code, GitHub is probably more advanced and professional.
BTW if this program is related to question about reading numbers from a file, remember you can store DATA and READ it all in one bas program without external files which are more of a hassel when it comes to sharing, distributing apps.
b = b + ...
|
|
|
Post by jarychk on Jul 8, 2024 17:35:36 GMT
take the simplest and easiest for sure! If you want to share code this is perfect place for beginners code, GitHub is probably more advanced and professional. BTW if this program is related to question about reading numbers from a file, remember you can store DATA and READ it all in one bas program without external files which are more of a hassel when it comes to sharing, distributing apps. b = b + ... And I now stand reminded about READ and DATA. I chose to make use of code for an options file, because I like the user to have more flexibility about the program's default values. I've become a little more accustomed to doing so with sequential file, but you are justified to say it is more complicated than READ & DATA. I best recall trying and finding this to be good in other little programs I tried to create: (I)Run a program. (II)Program will use an options file, being a simple sequential file. (III)Early in the starting of program, it checks to be sure the options file (1) is created and (2) is the correct quality. In case the file contents not correct, program remakes the file with default values. (IV)User can make changes to the options during any session with the program, and these choices will be kept in the revised options file. (No way to make a numbered list or bulleted list here?) (Not written as neatly as desired; using Roman Numerals like see here.)
|
|
|
Post by plus on Jul 8, 2024 18:54:21 GMT
OK if you want 3 numbers FROM USER it makes more since to use a file. I would use 3 INPUTs or 3 textboxes. But I haven't a clue what you have in mind since no code was posted.
b = b + ...
|
|
|
Post by jarychk on Jul 9, 2024 3:08:48 GMT
***(If you are interested in test-running or trying this program, take the code from the post headed by bean_up_0.122.bas! That one is much better.)***
bean_up, version 0.1 A coffee beans roasting and servings application
WHO INTERESTED: Person who roasts coffee at home
PURPOSE: Calculate between quantity in volume of unroasted green coffee beans and number of servings for brewed coffee drink
MORE FULL DESCRIPTION:
Coffee beans expand in being roasted so the volume of the roasted result is larger than the volume of the unroasted beans. The program does either of two things. User gives what volume of green beans he will roast, and progrm tells him how many servings the result will be (which may be just a good prediction); user may give a specified number of coffee drink/brewed servings, and program tells him how much (by volume) green coffee to roast.
Options values are important. The user should know or be able to determine empirically what quantity of unroasted green beans will become what quantity of roasted beans; this may vary depending on the particular coffee and on the level of roast. The user shoud/must pick the amount of roasted coffee which gives 1 serving. Likely ranges for this can be between 1 tablespoon and about 1.5 tablespoons.
These options should be set by the user, but if not present then default values will be created by the program and stored in a sequential text file.
TESTERS, USERS, ENSURE THIS: If someone wishes to test, or try, or use bean_up, then create a dedicated folder for it; and run the program in that location. So at the *.BAS level of develping and test/trying the necessary part of directories if the folder holding the files is named "bean_up_coffee", then this folder must contain bean_up_0.1.bas and the options file initially does not need to be placed there. The first run of bean_up will create the options file, called beanupoptions.txt
STILL A FEW FAULTS: A few more details could use refinement. Accuracy could be improved in a couple of places. Coding for proper and safe sequence of interfaces openings and closings has not yet been examined closely.
Here is the code, but with almost all of my development documentation mostly omitted from this code:
'VARIABLES 'rr part of ratio volume roasted beans, finished roasting 'rg part of ratio vol green beans, before roast 'd dose of ROASTED beans in 1 serving ' 'INPUT OR OUTPUT VARIABLES ' xgrn$ amount of unroasted green beans ' c number of servings when coffee brew 'FILE FOR OPTIONS 'beanupoptions.txt
'establish options file open "beanupoptions.txt" for append as #oopt close #oopt 'options file MUST have some data open "beanupoptions.txt" for input as #chk1 szchk=lof(#chk1) close #chk1 ' if szchk<9 then open "beanupoptions.txt" for output as #bld print #bld,1 print #bld,1 print #bld,1 close #bld end if ' 'options variables need the file values open "beanupoptions.txt" for input as #see input #see,rr input #see, rg input #see,d close #see ' print "options as variables for program run are ";rr;", ";rg;", ";d
' nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #front.statictext1, "how many servings?", 30, 106, 144, 20 statictext #front.statictext2, "how much green beans to use?", 30, 156, 200, 25 button #front.button3, "OK", [button3Click], UL, 278, 101, 102, 25 button #front.button4, "OK", [button4Click], UL, 278, 151, 102, 25 statictext #front.statictext5, "WHAT RESULTS YOU WANT?", 22, 50, 195, 20 button #front.button6, "Options", [button6Click], UL, 406, 16, 122, 25 button #front.button7, "information", [button7Click], UL, 30, 306, 122, 25 open "bean_up" for window as #front print #front, "trapclose [quit.front]"
print #front, "font ms_sans_serif 10"
wait
[quit.front] Close #front END
[button3Click] 'compute number of serving given input amount green beans ''''''''''''''''''''''''''''
'nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #serv.statictext1, "How much green unroasted beans?", 22, 81, 232, 20 textbox #serv.textbox2, 278, 76, 100, 25 button #serv.bserv, "find servings", [buttonserv], UL, 22, 131, 122, 25 statictext #serv.servescount, "show serves count", 182, 136, 296, 25 open "Known amount unroasted, find servings" for window as #serv print #serv, "trapclose [quit.serv]"
print #serv, "font ms_sans_serif 10"
wait
[quit.serv] Close #serv WAIT 'this waiting statement was very important, proper closing of handles ' END
[buttonserv] 'Perform action for the button named 'bserv' 'Insert your own code here print #serv.textbox2,"!contents? xgrn$" if val(xgrn$)<=0 then 'fixed possible tiny mistake notice "MISTAKEN INPUT - Need to redo" close #serv wait end if xgrn=val(xgrn$) c=xgrn*(rr/rg)*(1/d) ' print #serv.servescount,str$(c);" servings of brew" ' close #serv
wait '''''''''''''''''''''''''''' wait
[button4Click] 'compute how much green beans for given number of servings '______________________________________________
'nomainwin
WindowWidth = 592 WindowHeight = 310
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #volg.statictext1, "How many servings wanted?", 22, 71, 192, 25 textbox #volg.textbox2, 246, 66, 100, 25 button #volg.vgreen, "find vol. of green", [buttonvgreen], UL, 390, 66, 168, 25 statictext #volg.statictext4, "green unroasted volume", 22, 141, 312, 25 open "Known number of servings - find volume green beans to use" for window as #volg print #volg, "trapclose [quit.volg]"
print #volg, "font ms_sans_serif 10"
wait
[quit.volg] Close #volg WAIT ' END
[buttonvgreen] 'Perform action for the button named 'vgreen' 'Insert your own code here 'What in the textbox? print #volg.textbox2,"!contents? c$" 'look for mistaken input if val(c$)<=0 then notice "MISTAKEN INPUT -- REDO!" wait end if 'should be okay to process and find result 'notice "results to see how much green, happen here" let c=val(c$) let xgrn=c*d*(rg/rr) 'let xgrn$=str$(xgrn) LET xgrn$=using("####.##",xgrn) 'display result in statictext control print #volg.statictext4,xgrn$;" volume units for that serving count" wait
'______________________________________________ wait
'''''''''''' [button6Click] 'options will be here
WindowWidth = 456 WindowHeight = 305
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #options.statictext1, "expected volume ratio Roasted to Green", 22, 71, 256, 20 statictext #options.statictext2, "roasted", 22, 101, 144, 20 statictext #options.statictext3, "unroasted(green)", 22, 131, 144, 20 textbox #options.textbox4, 166, 96, 100, 25 textbox #options.textbox5, 166, 131, 100, 25 statictext #options.statictext6, "volume dose of roasted in 1 serving", 22, 191, 240, 20 textbox #options.textbox7, 286, 186, 100, 25 button #options.button8, "ACCEPT", [button8Click], UL, 294, 226, 88, 25 open "options - ratio and roasted bean dose" for window as #options print #options, "trapclose [quit.options]"
print #options, "font ms_sans_serif 10"
'show current option values in the textboxes. print #options.textbox4,rr print #options.textbox5,rg print #options.textbox7,d
wait
[quit.options] Close #options wait 'END
[button8Click] 'to accept the options print #options.textbox4,"!contents? rr" print #options.textbox5,"!contents? rg" print #options.textbox7,"!contents? d" ' open "beanupoptions.txt" for output as #uopt print #uopt,rr print #uopt,rg print #uopt, d close #uopt
close #options
wait '''''''''''''
[button7Click] 'information to help inform the user
'bean_up_info_study
st$=chr$(13)+" " sk$=chr$(13)+chr$(13)+" "
notice "bean_up version 0.1"+st$_ +"BEAN_UP, version 0.1"+sk$_ +"For the home coffee roaster - calculate between un-"+st$_ +"roasted green coffee beans and number of brewed servings."+sk$_ +"Measurement unit of roasted and unroasted beans are"+st$_ +"for consistant VOLUME unit; for example, in tablespoon."+sk$_ +"OPTIONS: User must know or empiracally determine what"+st$_ +"volume of roasted beans correspond to what volume of"+st$_ +"unroasted green beans. Also decide on precise dose"+st$_ +"of finished roasted beans which make for 1 serving."+st$_ +"These options may vary, depending on the coffee or"+st$_ +"the user's prefernces."+sk$_ +"-----------------------------------------------------"+sk$_ +"(c) jarych, July 7, 2024"+st$_ +"Development Tool : Just BASIC v2.0, a product of Shoptalk Systems."+sk$_ +"bean_up program is still in development and has a few "+st$_ +"program execution faults. Not for commercial use; "+st$_ +"currently adequate for most leisure home users."+st$_ +"Do not disassemble the package."
wait
|
|
|
Post by jarychk on Jul 9, 2024 6:42:58 GMT
Improvement to include flag variables to ensure clean closing of the chief interface window. User might open the program, open another window through a button; but might then choose to close the main program window without first finishing the other opened window/s. Now closure of whole program will be done cleanly.
'VARIABLES 'rr part of ratio volume roasted beans, finished roasting 'rg part of ratio vol green beans, before roast 'd dose of ROASTED beans in 1 serving ' 'INPUT OR OUTPUT VARIABLES ' xgrn$ amount of unroasted green beans ' c number of servings when coffee brew 'FILE FOR OPTIONS 'beanupoptions.txt 'WINDOW FLAG VARIABLES flagServ=0 flagVolg=0 flagOpt=0
'establish options file open "beanupoptions.txt" for append as #oopt close #oopt 'options file MUST have some data open "beanupoptions.txt" for input as #chk1 szchk=lof(#chk1) close #chk1 ' if szchk<9 then open "beanupoptions.txt" for output as #bld print #bld,1 print #bld,1 print #bld,1 close #bld end if ' 'options variables need the file values open "beanupoptions.txt" for input as #see input #see,rr input #see, rg input #see,d close #see ' print "options as variables for program run are ";rr;", ";rg;", ";d
' nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #front.statictext1, "how many servings?", 30, 106, 144, 20 statictext #front.statictext2, "how much green beans to use?", 30, 156, 200, 25 button #front.button3, "OK", [button3Click], UL, 278, 101, 102, 25 button #front.button4, "OK", [button4Click], UL, 278, 151, 102, 25 statictext #front.statictext5, "WHAT RESULTS YOU WANT?", 22, 50, 195, 20 button #front.button6, "Options", [button6Click], UL, 406, 16, 122, 25 button #front.button7, "information", [button7Click], UL, 30, 306, 122, 25 open "bean_up" for window as #front print #front, "trapclose [quit.front]"
print #front, "font ms_sans_serif 10"
wait
[quit.front] 'look at flag of each lower level window and act if needed if flagServ=1 then close #serv if flagVolg=1 then close #volg if flagOpt=1 then close #options
Close #front END
[button3Click] 'compute number of serving given input amount green beans ''''''''''''''''''''''''''''
'nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #serv.statictext1, "How much green unroasted beans?", 22, 81, 232, 20 textbox #serv.textbox2, 278, 76, 100, 25 button #serv.bserv, "find servings", [buttonserv], UL, 22, 131, 122, 25 statictext #serv.servescount, "show serves count", 182, 136, 296, 25 open "Known amount unroasted, find servings" for window as #serv print #serv, "trapclose [quit.serv]"
print #serv, "font ms_sans_serif 10" let flagServ=1
wait
[quit.serv] Close #serv flagServ=0 WAIT 'this waiting statement was very important, proper closing of handles ' END
[buttonserv] 'Perform action for the button named 'bserv' 'Insert your own code here print #serv.textbox2,"!contents? xgrn$" if val(xgrn$)<=0 then 'fixed possible tiny mistake notice "MISTAKEN INPUT - Need to redo" close #serv wait end if xgrn=val(xgrn$) c=xgrn*(rr/rg)*(1/d) ' print #serv.servescount,str$(c);" servings of brew" ' close #serv
wait '''''''''''''''''''''''''''' wait
[button4Click] 'compute how much green beans for given number of servings '______________________________________________
'nomainwin
WindowWidth = 592 WindowHeight = 310
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #volg.statictext1, "How many servings wanted?", 22, 71, 192, 25 textbox #volg.textbox2, 246, 66, 100, 25 button #volg.vgreen, "find vol. of green", [buttonvgreen], UL, 390, 66, 168, 25 statictext #volg.statictext4, "green unroasted volume", 22, 141, 312, 25 open "Known number of servings - find volume green beans to use" for window as #volg print #volg, "trapclose [quit.volg]"
print #volg, "font ms_sans_serif 10" LET flagVolg=1
wait
[quit.volg] Close #volg flagVolg=0 WAIT ' END
[buttonvgreen] 'Perform action for the button named 'vgreen' 'Insert your own code here 'What in the textbox? print #volg.textbox2,"!contents? c$" 'look for mistaken input if val(c$)<=0 then notice "MISTAKEN INPUT -- REDO!" wait end if 'should be okay to process and find result 'notice "results to see how much green, happen here" let c=val(c$) let xgrn=c*d*(rg/rr) 'let xgrn$=str$(xgrn) LET xgrn$=using("####.##",xgrn) 'display result in statictext control print #volg.statictext4,xgrn$;" volume units for that serving count" wait
'______________________________________________ wait
'''''''''''' [button6Click] 'options will be here
WindowWidth = 456 WindowHeight = 305
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #options.statictext1, "expected volume ratio Roasted to Green", 22, 71, 256, 20 statictext #options.statictext2, "roasted", 22, 101, 144, 20 statictext #options.statictext3, "unroasted(green)", 22, 131, 144, 20 textbox #options.textbox4, 166, 96, 100, 25 textbox #options.textbox5, 166, 131, 100, 25 statictext #options.statictext6, "volume dose of roasted in 1 serving", 22, 191, 240, 20 textbox #options.textbox7, 286, 186, 100, 25 button #options.button8, "ACCEPT", [button8Click], UL, 294, 226, 88, 25 open "options - ratio and roasted bean dose" for window as #options print #options, "trapclose [quit.options]"
print #options, "font ms_sans_serif 10" LET flagOpt=1
'show current option values in the textboxes. print #options.textbox4,rr print #options.textbox5,rg print #options.textbox7,d
wait
[quit.options] Close #options flagOpt=0 wait 'END
[button8Click] 'to accept the options print #options.textbox4,"!contents? rr" print #options.textbox5,"!contents? rg" print #options.textbox7,"!contents? d" ' open "beanupoptions.txt" for output as #uopt print #uopt,rr print #uopt,rg print #uopt, d close #uopt
close #options flagOpt=0
wait '''''''''''''
[button7Click] 'information to help inform the user
'bean_up_info_study
st$=chr$(13)+" " sk$=chr$(13)+chr$(13)+" "
notice "bean_up version 0.11"+st$_ +"BEAN_UP, version 0.11"+sk$_ +"For the home coffee roaster - calculate between un-"+st$_ +"roasted green coffee beans and number of brewed servings."+sk$_ +"Measurement unit of roasted and unroasted beans are"+st$_ +"for consistant VOLUME unit; for example, in tablespoon."+sk$_ +"OPTIONS: User must know or empiracally determine what"+st$_ +"volume of roasted beans correspond to what volume of"+st$_ +"unroasted green beans. Also decide on precise dose"+st$_ +"of finished roasted beans which make for 1 serving."+st$_ +"These options may vary, depending on the coffee or"+st$_ +"the user's prefernces."+sk$_ +"-----------------------------------------------------"+sk$_ +"(c) jarych, July 8, 2024"+st$_ +"Development Tool : Just BASIC v2.0, a product of Shoptalk Systems."+sk$_ +"bean_up program is still in development and has a few "+st$_ +"program execution faults. Not for commercial use; "+st$_ +"currently adequate for most leisure home users."+st$_ +"Do not disassemble the package."
wait
|
|
|
Post by tsh73 on Jul 9, 2024 9:11:36 GMT
Hello jarych I was able to break it a few times ;) so my findings: 1) 0 is not valid in any of options (ends up with divide by 0 then calculating) 2) on two calcutlating windows, both check for 0 But one window is closed after message, while other stays - looks unconsistent 3) if I open options or calculating window and then try to open it AGAIN program dies. Since you already have flags for windows, it's easy fix.
suggestions: * use setfocus on a text field so in new window you can type right away * use default button (needs converting type of window to dialog) so after entering number you just press Enter and button (ACCEPT) got pressed.
also, on first start, user should go to options and set numbers That info is not in the program
|
|
|
Post by plus on Jul 9, 2024 12:59:02 GMT
I have not studied code but it sure looks like we are cooking with butter now! Great verbal description of your app jarychk ! PS I happen to be trying to cut back on coffee because I don't want to be addicted to anything except coding maybe ![:)](//storage.proboards.com/forum/images/smiley/smiley.png) b = b + ...
|
|
|
Post by jarychk on Jul 9, 2024 16:25:24 GMT
Thanks for looking through some tries, tsh73. bean_up seems to work acceptably if I do not try to break it. I say in the documentation to user ("information"), that still in development and may have faults. Still needs some refinements. Regarding the default values for options, I will handle those differently; not really exactly the way you suggest. There are better default values than the ones in the program's code. ( plus, noted.)
|
|
|
Post by tsh73 on Jul 9, 2024 20:38:36 GMT
Ah, but that's the best part of it! ;)
|
|
|
Post by jarychk on Jul 10, 2024 2:56:47 GMT
bean_up_0.12.bas An improvement for those who want to try.
Most additions to work with options, including (rr)/(rg) must be greater than 1. (volume of roasted bean quantity must be larger than the volume of the same beans before roasting.)
Most of the development version notes is omitted.
' bean_up_0.12 make some checking for bad input for options section - not working - ok now flag spelling
'VARIABLES 'rr part of ratio volume roasted beans, finished roasting 'rg part of ratio vol green beans, before roast 'd dose of ROASTED beans in 1 serving ' 'INPUT OR OUTPUT VARIABLES ' xgrn$ amount of unroasted green beans ' c number of servings when coffee brew 'FILE FOR OPTIONS 'beanupoptions.txt 'WINDOW FLAG VARIABLES flagServ=0 flagVolg=0 flagOpt=0 ' flagwrongo=0 'control flag in case options input bad
'establish options file open "beanupoptions.txt" for append as #oopt close #oopt 'options file MUST have some data open "beanupoptions.txt" for input as #chk1 szchk=lof(#chk1) close #chk1 ' if szchk<9 then open "beanupoptions.txt" for output as #bld print #bld,1 print #bld,1 print #bld,1 close #bld end if ' 'options variables need the file values open "beanupoptions.txt" for input as #see input #see,rr input #see, rg input #see,d close #see ' print "options as variables for program run are ";rr;", ";rg;", ";d
' nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #front.statictext1, "how many servings?", 30, 106, 144, 20 statictext #front.statictext2, "how much green beans to use?", 30, 156, 200, 25 button #front.button3, "OK", [button3Click], UL, 278, 101, 102, 25 button #front.button4, "OK", [button4Click], UL, 278, 151, 102, 25 statictext #front.statictext5, "WHAT RESULTS YOU WANT?", 22, 50, 195, 20 button #front.button6, "Options", [button6Click], UL, 406, 16, 122, 25 button #front.button7, "information", [button7Click], UL, 30, 306, 122, 25 open "bean_up" for window as #front print #front, "trapclose [quit.front]"
print #front, "font ms_sans_serif 10"
wait
[quit.front] 'look at flag of each lower level window and act if needed if flagServ=1 then close #serv if flagVolg=1 then close #volg if flagOpt=1 then close #options
Close #front END
[button3Click] 'compute number of serving given input amount green beans ''''''''''''''''''''''''''''
'nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #serv.statictext1, "How much green unroasted beans?", 22, 81, 232, 20 textbox #serv.textbox2, 278, 76, 100, 25 button #serv.bserv, "find servings", [buttonserv], UL, 22, 131, 122, 25 statictext #serv.servescount, "show serves count", 182, 136, 296, 25 open "Known amount unroasted, find servings" for window as #serv print #serv, "trapclose [quit.serv]"
print #serv, "font ms_sans_serif 10" let flagServ=1
wait
[quit.serv] Close #serv flagServ=0 WAIT 'this waiting statement was very important, proper closing of handles ' END
[buttonserv] 'Perform action for the button named 'bserv' 'Insert your own code here print #serv.textbox2,"!contents? xgrn$" if val(xgrn$)<=0 then 'fixed possible tiny mistake notice "MISTAKEN INPUT - Need to redo" close #serv wait end if xgrn=val(xgrn$) c=xgrn*(rr/rg)*(1/d) ' print #serv.servescount,str$(c);" servings of brew" ' close #serv
wait '''''''''''''''''''''''''''' wait
[button4Click] 'compute how much green beans for given number of servings '______________________________________________
'nomainwin
WindowWidth = 592 WindowHeight = 310
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #volg.statictext1, "How many servings wanted?", 22, 71, 192, 25 textbox #volg.textbox2, 246, 66, 100, 25 button #volg.vgreen, "find vol. of green", [buttonvgreen], UL, 390, 66, 168, 25 statictext #volg.statictext4, "green unroasted volume", 22, 141, 312, 25 open "Known number of servings - find volume green beans to use" for window as #volg print #volg, "trapclose [quit.volg]"
print #volg, "font ms_sans_serif 10" LET flagVolg=1
wait
[quit.volg] Close #volg flagVolg=0 WAIT ' END
[buttonvgreen] 'Perform action for the button named 'vgreen' 'Insert your own code here 'What in the textbox? print #volg.textbox2,"!contents? c$" 'look for mistaken input if val(c$)<=0 then notice "MISTAKEN INPUT -- REDO!" wait end if 'should be okay to process and find result 'notice "results to see how much green, happen here" let c=val(c$) let xgrn=c*d*(rg/rr) 'let xgrn$=str$(xgrn) LET xgrn$=using("####.##",xgrn) 'display result in statictext control print #volg.statictext4,xgrn$;" volume units for that serving count" wait
'______________________________________________ wait
'''''''''''' [button6Click] 'options will be here
WindowWidth = 456 WindowHeight = 305
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #options.statictext1, "expected volume ratio Roasted to Green", 22, 71, 256, 20 statictext #options.statictext2, "roasted", 22, 101, 144, 20 statictext #options.statictext3, "unroasted(green)", 22, 131, 144, 20 textbox #options.textbox4, 166, 96, 100, 25 textbox #options.textbox5, 166, 131, 100, 25 statictext #options.statictext6, "volume dose of roasted in 1 serving", 22, 191, 240, 20 textbox #options.textbox7, 286, 186, 100, 25 button #options.button8, "ACCEPT", [button8Click], UL, 294, 226, 88, 25 open "options - ratio and roasted bean dose" for window as #options print #options, "trapclose [quit.options]"
print #options, "font ms_sans_serif 10" LET flagOpt=1
'show current option values in the textboxes. print #options.textbox4,rr print #options.textbox5,rg print #options.textbox7,d
wait
[quit.options] Close #options flagOpt=0 wait 'END
[button8Click] 'to accept the options print #options.textbox4,"!contents? rr" print #options.textbox5,"!contents? rg" print #options.textbox7,"!contents? d" ' 'Are those input values valid? if rr<1 or rg<1 or d<1 then flagwrongo=1 if rr<rg then flagwrongo=1 ' if flagwrongo=1 then notice "SOME INPUT IS BAD! FIX THAT!" let flagwrongo=0 wait end if ' open "beanupoptions.txt" for output as #uopt print #uopt,rr print #uopt,rg print #uopt, d close #uopt
close #options flagOpt=0
wait '''''''''''''
[button7Click] 'information to help inform the user
'bean_up_info_study
st$=chr$(13)+" " sk$=chr$(13)+chr$(13)+" "
notice "bean_up version 0.11"+st$_ +"BEAN_UP, version 0.11"+sk$_ +"For the home coffee roaster - calculate between un-"+st$_ +"roasted green coffee beans and number of brewed servings."+sk$_ +"Measurement unit of roasted and unroasted beans are"+st$_ +"for consistant VOLUME unit; for example, in tablespoon."+sk$_ +"OPTIONS: User must know or empiracally determine what"+st$_ +"volume of roasted beans correspond to what volume of"+st$_ +"unroasted green beans. Also decide on precise dose"+st$_ +"of finished roasted beans which make for 1 serving."+st$_ +"These options may vary, depending on the coffee or"+st$_ +"the user's prefernces."+sk$_ +"-----------------------------------------------------"+sk$_ +"(c) jarych, July 8, 2024"+st$_ +"Development Tool : Just BASIC v2.0, a product of Shoptalk Systems."+sk$_ +"bean_up program is still in development and has a few "+st$_ +"program execution faults. Not for commercial use; "+st$_ +"currently adequate for most leisure home users."+st$_ +"Do not disassemble the package."
wait
There is still another small problem detail about options that I need to fix. And a couple of other small problems.
|
|
|
Post by jarychk on Jul 10, 2024 6:41:21 GMT
bean_up_0.122.bas
Better than the other posted versions. Open & close of interfaces, easy input-focus. Still may need to check about accuracy controlling. Volume measurement unit may be unclear.
This program code is with most of my development notes omitted:
' bean_up_0.121 small corrections documenting and options ' bean_up_0.122 fixed flag problem between #front and #serv. setfocus for proper controls in windows
'VARIABLES 'rr part of ratio volume roasted beans, finished roasting 'rg part of ratio vol green beans, before roast 'd dose of ROASTED beans in 1 serving ' 'INPUT OR OUTPUT VARIABLES ' xgrn$ amount of unroasted green beans ' c number of servings when coffee brew 'FILE FOR OPTIONS 'beanupoptions.txt 'WINDOW FLAG VARIABLES flagServ=0 flagVolg=0 flagOpt=0 ' flagwrongo=0 'control flag in case options input bad
'establish options file open "beanupoptions.txt" for append as #oopt close #oopt 'options file MUST have some data open "beanupoptions.txt" for input as #chk1 szchk=lof(#chk1) close #chk1 ' if szchk<9 then open "beanupoptions.txt" for output as #bld print #bld,3 print #bld,2 print #bld,1 close #bld end if ' 'options variables need the file values open "beanupoptions.txt" for input as #see input #see,rr input #see, rg input #see,d close #see ' print "options as variables for program run are ";rr;", ";rg;", ";d
' nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #front.statictext1, "how many servings?", 30, 106, 144, 20 statictext #front.statictext2, "how much green beans to use?", 30, 156, 200, 25 button #front.button3, "OK", [button3Click], UL, 278, 101, 102, 25 button #front.button4, "OK", [button4Click], UL, 278, 151, 102, 25 statictext #front.statictext5, "WHAT RESULTS YOU WANT?", 22, 50, 195, 20 button #front.button6, "Options", [button6Click], UL, 406, 16, 122, 25 button #front.button7, "information", [button7Click], UL, 30, 306, 122, 25 open "bean_up" for window as #front print #front, "trapclose [quit.front]"
print #front, "font ms_sans_serif 10" print #front.button6,"!setfocus"
wait
[quit.front] 'look at flag of each lower level window and act if needed if flagServ=1 then close #serv if flagVolg=1 then close #volg if flagOpt=1 then close #options
Close #front END
[button3Click] 'compute number of serving given input amount green beans ''''''''''''''''''''''''''''
'nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #serv.statictext1, "How much green unroasted beans?", 22, 81, 232, 20 textbox #serv.textbox2, 278, 76, 100, 25 button #serv.bserv, "find servings", [buttonserv], UL, 22, 131, 122, 25 statictext #serv.servescount, "show serves count", 182, 136, 296, 25 open "Known amount unroasted, find servings" for window as #serv print #serv, "trapclose [quit.serv]"
print #serv, "font ms_sans_serif 10" print #serv.textbox2,"!setfocus" let flagServ=1
wait
[quit.serv] Close #serv flagServ=0 WAIT 'this waiting statement was very important, proper closing of handles ' END
[buttonserv] 'Perform action for the button named 'bserv' 'Insert your own code here print #serv.textbox2,"!contents? xgrn$" if val(xgrn$)<=0 then 'fixed possible tiny mistake notice "MISTAKEN INPUT - Need to redo" close #serv flagServ=0 'RESETING flag for #serv wait end if xgrn=val(xgrn$) c=xgrn*(rr/rg)*(1/d) ' print #serv.servescount,str$(c);" servings of brew" ' close #serv
wait '''''''''''''''''''''''''''' wait
[button4Click] 'compute how much green beans for given number of servings '______________________________________________
'nomainwin
WindowWidth = 592 WindowHeight = 310
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #volg.statictext1, "How many servings wanted?", 22, 71, 192, 25 textbox #volg.textbox2, 246, 66, 100, 25 button #volg.vgreen, "find vol. of green", [buttonvgreen], UL, 390, 66, 168, 25 statictext #volg.statictext4, "green unroasted volume", 22, 141, 312, 25 open "Known number of servings - find volume green beans to use" for window as #volg print #volg, "trapclose [quit.volg]"
print #volg, "font ms_sans_serif 10" print #volg.textbox2,"!setfocus" LET flagVolg=1
wait
[quit.volg] Close #volg flagVolg=0 WAIT ' END
[buttonvgreen] 'Perform action for the button named 'vgreen' 'Insert your own code here 'What in the textbox? print #volg.textbox2,"!contents? c$" 'look for mistaken input if val(c$)<=0 then notice "MISTAKEN INPUT -- REDO!" wait end if 'should be okay to process and find result 'notice "results to see how much green, happen here" let c=val(c$) let xgrn=c*d*(rg/rr) 'let xgrn$=str$(xgrn) LET xgrn$=using("####.##",xgrn) 'display result in statictext control print #volg.statictext4,xgrn$;" volume units for that serving count" wait
'______________________________________________ wait
'''''''''''' [button6Click] 'options will be here
WindowWidth = 456 WindowHeight = 305
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #options.statictext1, "expected volume ratio Roasted to Green", 22, 71, 256, 20 statictext #options.statictext2, "roasted", 22, 101, 144, 20 statictext #options.statictext3, "unroasted(green)", 22, 131, 144, 20 textbox #options.textbox4, 166, 96, 100, 25 textbox #options.textbox5, 166, 131, 100, 25 statictext #options.statictext6, "volume dose of roasted in 1 serving", 22, 191, 240, 20 textbox #options.textbox7, 286, 186, 100, 25 button #options.button8, "ACCEPT", [button8Click], UL, 294, 226, 88, 25 open "options - ratio and roasted bean dose" for window as #options print #options, "trapclose [quit.options]"
print #options, "font ms_sans_serif 10" print #options.textbox4,"!setfocus" LET flagOpt=1
'show current option values in the textboxes. print #options.textbox4,rr print #options.textbox5,rg print #options.textbox7,d
wait
[quit.options] Close #options flagOpt=0 wait 'END
[button8Click] 'to accept the options print #options.textbox4,"!contents? rr" print #options.textbox5,"!contents? rg" print #options.textbox7,"!contents? d" ' 'Are those input values valid? if rr<1 or rg<1 or d<1 then flagwrongo=1 if rr<rg then flagwrongo=1 ' if flagwrongo=1 then notice "SOME INPUT IS BAD! FIX THAT!" let flagwrongo=0 wait end if ' open "beanupoptions.txt" for output as #uopt print #uopt,rr print #uopt,rg print #uopt, d close #uopt
close #options flagOpt=0
wait '''''''''''''
[button7Click] 'information to help inform the user
'bean_up_info_study
st$=chr$(13)+" " sk$=chr$(13)+chr$(13)+" "
notice "bean_up version 0.121"+st$_ +"BEAN_UP, version 0.121"+sk$_ +"For the home coffee roaster - calculate between un-"+st$_ +"roasted green coffee beans and number of brewed servings."+sk$_ +"Measurement unit of roasted and unroasted beans are"+st$_ +"for consistant VOLUME unit; for example, in tablespoon."+sk$_ +"OPTIONS: User must know or empiracally determine what"+st$_ +"volume of roasted beans correspond to what volume of"+st$_ +"unroasted green beans. Also decide on precise dose"+st$_ +"of finished roasted beans which make for 1 serving."+st$_ +"These options may vary, depending on the coffee or"+st$_ +"the user's prefernces."+sk$_ +"-----------------------------------------------------"+sk$_ +"(c) jarychk, July 8, 2024"+st$_ +"Development Tool : Just BASIC v2.0, a product of Shoptalk Systems."+sk$_ +"bean_up program is still in development and has a few "+st$_ +"program execution faults. Not for commercial use; "+st$_ +"currently adequate for most leisure home users."+st$_ +"Do not disassemble the package."
wait
Still need to adjust documentation-in-program about version 'number'.
|
|
|
Post by tsh73 on Jul 10, 2024 7:03:17 GMT
Hello jarychk You can put your version number in variable up in the program then use elsewhere
ver$="0.122"
'...
st$=chr$(13)+" " sk$=chr$(13)+chr$(13)+" "
notice "bean_up version "+ver$+st$ _ +"BEAN_UP, version "+ver$+sk$ _ +"..."
|
|