WinMeasure

Post Reply
User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

WinMeasure

Post by rbytes »

This is a simple program to use your laptop or tablet as a measuring tool. There are some commented-out code lines that I hope to use once there is a #.hide() command for objects.

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 ->
Attachments
Screenshot (43).png
Screenshot (43).png (154.33 KiB) Viewed 1328 times
Screenshot (42).png
Screenshot (42).png (195.36 KiB) Viewed 1328 times
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: WinMeasure

Post by Mr. Kibernetik »

In SPL the system UI object groups like #.button are a kind of templates to be copied to real buttons, but they are not read-only.
This means that if you need 5 buttons with, say, 120 points width, you can setup your system group like this:

Code: Select all

#.button.width = 120
and all subsequent assigns from system group #.button to other buttons will provide objects with width 120:

Code: Select all

b,c,d,e,f = #.button 'create all your buttons
Another similar approach if you don't want to modify system object #.button, can be:

setup your default button

Code: Select all

mybutton = #.button
mybutton.width = 120
and so on - setup all other necessary properties, and then do:

Code: Select all

b,c,d,e,f = mybutton
so all properties will be just copied from mybutton to b,c,d,e,f buttons.

SPL is very flexible in this regard.

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: WinMeasure

Post by rbytes »

Thanks for this information. :)
The only thing that gets me down is gravity...

Post Reply