Older Version Newer Version

cogburn cogburn May 23, 2012

**Program that allows practice reading a metric ruler.** I got some more help from the LB forum guys to put together this program. It allows the user to read and input the observed length of a rectangle. It gives the user 5 different rectangles to measure and it gives instant feedback as well as it saves a copy of the results to a file. ****CautionCaution on the use of the program.** **Makeprogram. Make sure that the file address is suitable for your computer. I worked off of a jump drive so the file was opened, written to, and saved on the g:\ drive. If you are working only on your c:**\ **drivec:**\** drive or some other drive, please change the file address code in the program to reflect the drive to which you are using to save the results.** ***results. * Otherwise, it is a straightforward program [[code format="lb"]] [[code]] 'This program attempts to give students practice reading a rule. '*** Must set file parameters for your particular situation '*** example "g:\record.txt" vs "c:\record.txt" '***************************************************** 'set graphics window parameters '***************************************************** nomainwin opennomainwin open "g:\record.txt" for append as #1 close close #1 kill"g:\record.txt" kill"g:\record.txt" UpperLeftXUpperLeftX = 500 UpperLeftY UpperLeftY = 150 WindowWidth WindowWidth = 640 WindowHeight WindowHeight = 760 graphicboxgraphicbox #w.g, 10, 10, 600, 500 statictext statictext #w.s, "Enter your measurement in the box and click 'Save' button", 10, 600, 600, 30 textbox textbox #w.tb1, 10, 550, 600, 32 button button #w.b1, "Save", [entered], LR, 300, 50, 60, 30 openopen "Measuring Practice" for window as #w #w,#w, "trapclose [quit]" #w.tb1 #w.tb1 "!font arial 16 bold" #w.s #w.s "!font arial 12" #w.tb1 #w.tb1 "!setfocus" '***************************************** 'draw'***************************************** 'draw the ruler borders '***************************************** #w.g, '***************************************** #w.g, "goto 50 400" #w.g, #w.g, "down" #w.g, #w.g, "goto 50 450" #w.g, #w.g, "goto 550 450" #w.g, #w.g, "goto 550 400" #w.g, #w.g, "goto 50 400" '******************************************* 'add'******************************************* 'add the centimeter and .5 centimeter markings '******************************************* [skip1] x '******************************************* [skip1] x = 50 y y = 400 z z = 425 forfor j = 1 to 19 x x = x + 25 #w.g, #w.g, "goto ";x;" ";y #w.g, #w.g, "down" #w.g, #w.g, "goto ";x;" ";z #w.g, #w.g, "up" next next j xx = 50 y y = 400 z z = 410 #w.g,#w.g, "up" #w.g, #w.g, "goto ";x;" ";z forfor i = 1 to 100 x x = x + 5 #w.g, #w.g, "goto ";x;" ";y #w.g, #w.g, "down" #w.g, #w.g, "goto ";x;" ";z #w.g, #w.g, "up" next next i '************************************************** 'print'************************************************** 'print the numbers 1-9 to label the centimeter marks '************************************************** x '************************************************** x = 95 y y = 430 d d = 1 #w.g,"down" #w.g, #w.g,"down" #w.g, "place ";x;" ";y print print #w.g, "\";d for for j = 1 to 8 d d = d+1 x x = x + 50 #w.g, #w.g, "place ";x;" ";y print print #w.g, "\";d next next j #w.g, #w.g, "flush" #w.g, #w.g, "up" '******************************************************* 'Draw'******************************************************* 'Draw a rectangle above the ruler and store length as cm '******************************************************* '******************************************************* forfor b = 1 to 5 #w.g, #w.g, "goto 50 400" #w.g, #w.g, "down" x x = 550:y = 350 print print #w.g, "backcolor white" print print #w.g, "color white" print print #w.g, "boxfilled ";x;" ";y #w.g, #w.g, "goto 50 400" #w.g, #w.g, "down" x=int(rnd(1)*450) x=int(rnd(1)*450) + 100:y=350 print print #w.g, "backcolor blue" print print #w.g, "box ";x;" ";y print print #w.g, "boxfilled ";x;" ";y print print #w.g,"flush" cm cm = (x-50)/50 i i = 2 rounded rounded = int(cm*10^i +0.5) / 10^i wait wait '************************************************* 'allow'************************************************* 'allow guess and compare with actual length of bar '************************************************* '************************************************* [entered] #w.tb1[entered] #w.tb1 "!contents? reply$" guess guess =val( reply$) if if ( rounded -0.1 <guess) and ( rounded +0.1 >guess) then #w.tb1 #w.tb1 "GOOD ANSWER" else #w.tb1 else #w.tb1 "The correct answer was "; rounded; " cm, not "; guess end end if timertimer 3000, [continue] wait [continue] wait [continue] '<- when time is up, execution branches here timer timer 0 #w.s#w.s "Measurement # "; b+1 #w.tb1 #w.tb1 "" #w.tb1 #w.tb1 "!setfocus" '************************************************* 'write'************************************************* 'write to file '************************************************* '************************************************* [save] open[save] open "g:\record.txt" for append as #1 'create a new file on disk print print #1, guess;",";rounded close close #1 next next b [grade] openopen "g:\record.txt" for input as #2 correct correct = 0 while while eof (#2) = 0 input input #2, guess, rounded IF rounded - .1 < guess AND rounded + .1 > guess THEN correct = correct + 1 ELSE correct = correct END IF wend #w.tb1 "% correct = ";(correct/5)*100 timer 3000, [finish] wait [finish] '<- when time is up, execution branches here timer 0 [quit] close#2 close #w end IF rounded - .1 < guess AND rounded + .1 > guess THEN correct = correct + 1 ELSE correct = correct END IF wend #w.tb1 "% correct = ";(correct/5)*100 timer 3000, [finish] wait [finish] '<- when time is up, execution branches here timer 0 [quit] close#2 close #w end [[code]] [[code]]