Code: Select all
''
WinMeasure by rbytes
September 2017
Uses graphic images of inch and metric rulers
You must set the width of the ruler images for
each device you use. Eg. a.width, b.width
and use an actual ruler to check the result.
''
' setup
#.angle(#.degrees)
' hide the side toolbar
#.scrview(#.normal)
mx,my = #.scrsize()
'#.scrclear(.5,.5,.5)
'#.drawrotate(0,0,180)
shift = 40
' load the inch ruler
a = #.image ' ruler image
a.source = "ruler.jpg"
a.width = 1760
a.x = -33
a.y = 0
'#.show(a)
' load and show the metric ruler
b = #.image ' ruler image
b.source = "ruler2.jpg"
b.width = 1760
b.x = -33
b.y = 0
#.show(b)
'#.scr()
' create a window for taking notes
c = #.textbox 'is a text box. Pressing "Enter" key if multi is 0 registers an action. Group elements are:
c.edit = 1 'if 0 then text box is a non-editable text label (default), otherwise text box is an editable text field for text input;
c.height = 400
multi = 1 ' if 0 then text box is single-line (default), otherwise it is multi-line;
c.text = "Notes: " 'text inside text box;
c.width = mx 'text box width;
c.x = 0 ' offset from left screen border;
c.y = 70 'offset from top screen border.
#.show(c)
'#.scr()
' button to show the inch ruler
d = #.button
d.height = 50
d.text = "I N C H"
d.width = 100
d.x = 300 + shift
d.y = 360
' button to show the metric ruler
e = #.button
e.height = 50
e.text = "C E N T"
e.width = 100
e.x = 450 + shift
e.y = 360
' button to save notes
f = #.button
f.height = 50
f.text = "S A V E"
f.width = 100
f.x = 600 + shift
f.y = 360
' button to quit
g = #.button
g.height = 50
g.text = "Q U I T"
g.width = 100
g.x = 750 + shift
g.y = 360
#.show(d,e,f,g)
' Main program loop
:loop
' if INCH button is pressed
? #.act(d)
'#.show(a) for future use
b.x = -19
b.source = "ruler.jpg"
.
' if CENT button is pressed
? #.act(e)
'#.show(b) ' for future use
b.x = -33
b.source = "ruler2.jpg"
.
' If SAVE button is pressed
? #.act(f)
k = "Notes.txt"
#.writetext(k,c.text)
.
If QUIT button is pressed
? #.act(g), #.end()
' Slow down the loop
#.delay(.1)
loop ->