Older Version
Newer Version
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. Caution on the use of the program. 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: \ 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. *
Otherwise, it is a straightforward program
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. Caution on the use of the program. 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: \ 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. *
Otherwise, it is a straightforward program
[[code]]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
open "g:\record.txt" for append as #1
close #1
kill"g:\record.txt"
UpperLeftX = 500
UpperLeftY = 150
WindowWidth = 640
WindowHeight = 760
graphicbox #w.g, 10, 10, 600, 500
statictext #w.s, "Enter your measurement in the box and click 'Save' button", 10, 600, 600, 30
textbox #w.tb1, 10, 550, 600, 32
button #w.b1, "Save", [entered], LR, 300, 50, 60, 30
open "Measuring Practice" for window as #w
#w, "trapclose [quit]"
#w.tb1 "!font arial 16 bold"
#w.s "!font arial 12"
#w.tb1 "!setfocus"
'*****************************************
'draw the ruler borders
'*****************************************
#w.g, "goto 50 400"
#w.g, "down"
#w.g, "goto 50 450"
#w.g, "goto 550 450"
#w.g, "goto 550 400"
#w.g, "goto 50 400"
'*******************************************
'add the centimeter and .5 centimeter markings
'*******************************************
[skip1]
x = 50
y = 400
z = 425
for j = 1 to 19
x = x + 25
#w.g, "goto ";x;" ";y
#w.g, "down"
#w.g, "goto ";x;" ";z
#w.g, "up"
next j
x = 50
y = 400
z = 410
#w.g, "up"
#w.g, "goto ";x;" ";z
for i = 1 to 100
x = x + 5
#w.g, "goto ";x;" ";y
#w.g, "down"
#w.g, "goto ";x;" ";z
#w.g, "up"
next i
'**************************************************
'print the numbers 1-9 to label the centimeter marks
'**************************************************
x = 95
y = 430
d = 1
#w.g,"down"
#w.g, "place ";x;" ";y
print #w.g, "\";d
for j = 1 to 8
d = d+1
x = x + 50
#w.g, "place ";x;" ";y
print #w.g, "\";d
next j
#w.g, "flush"
#w.g, "up"
'*******************************************************
'Draw a rectangle above the ruler and store length as cm
'*******************************************************
for b = 1 to 5
#w.g, "goto 50 400"
#w.g, "down"
x = 550:y = 350
print #w.g, "backcolor white"
print #w.g, "color white"
print #w.g, "boxfilled ";x;" ";y
#w.g, "goto 50 400"
#w.g, "down"
x=int(rnd(1)*450) + 100:y=350
print #w.g, "backcolor blue"
print #w.g, "box ";x;" ";y
print #w.g, "boxfilled ";x;" ";y
print #w.g,"flush"
cm = (x-50)/50
i = 2
rounded = int(cm*10^i +0.5) / 10^i
wait
'*************************************************
'allow guess and compare with actual length of bar
'*************************************************
[entered]
#w.tb1 "!contents? reply$"
guess =val( reply$)
if ( rounded -0.1 <guess) and ( rounded +0.1 >guess) then
#w.tb1 "GOOD ANSWER"
else
#w.tb1 "The correct answer was "; rounded; " cm, not "; guess
end if
timer 3000, [continue]
wait
[continue] '<- when time is up, execution branches here
timer 0
#w.s "Measurement # "; b+1
#w.tb1 ""
#w.tb1 "!setfocus"
'*************************************************
'write to file
'*************************************************
[save]
open "g:\record.txt" for append as #1 'create a new file on disk
print #1, guess;",";rounded
close #1
next b
[grade]
open "g:\record.txt" for input as #2
correct = 0
while eof (#2) = 0
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