Scaling the width of a button

I am using a button as a horizontal bar graph.

My value it will read from is in the range of 0 to 15. If I use Set Width % then the 15 value is a very small bar of the full 100% available. How do I scale the bar to show full at 15?

Here I use a 0-15 slider to change the button width.
button_width_variable.aia (1.7 KB)

Capture

ABG I did see that post but my zero to 15 is incoming text from blutooth so I cant see how the slider would help?

probably just being thick.....

ABG I tried these blocks.

The thinking being splitdata is the incoming number which in this case is 0-5. I check for that then create a new variable (batt) that is 20 times bigger (to scale to 100% on screen).

That should work.
My slider was just to exercise the scaling formula.

Blocks are attached.
If I replace the SET BATT.width block set with the ones disabled on the right, I get a too many arguments error? (obviously I need to replace TEMP and FUEL SET's as well but wanted to test with just BATT to start).

If I just run the code on the left it works fine except it doesn't scale the buttons.

At the places where you assign each width you need to squeeze in a call to a scale function, with the scale limit and the current data value:
(draggable)
math.aia (28.1 KB) scaled_percent_test1

(I added the max(1) call to avoid crashes (divide by 0) if some one passes 0 as max.)

Sorry....few questions here....

I cant find the call,max,x block anywhere?

when you say 'where i assign the value' do you mean after the Set BATT widthPercent (in that one case).?

When you say data value to you mean the value received at the list position?

I clearly dont understand.....yet...

It's a builtin math block.

Jam it into its mouth.

Yes

Reading on value procedures:
http://www.appinventor.org/bookChapters/chapter21.pdf

from free AI2 book at FAQ Section: Books, Tips, Tutorials for AI2

My blue maths built in blocks dont have a call function and neither do the purple procedures ones??

and my data value in this case is global splitdata but how do i tell it to use position 1 in the list?

Thanks for the reading tips......

http://www.appinventor.org/book2

Chapter 19

Ok I am being a pain now but.......

Just cant find a purple call anywhere???

OK got it.

Create the procedure then the call function appears in the built in. Great.

Now to work out how to attach the maths

ABG

Thanks so much. I have implemented in on the BATT button only for now and it seems to work....

Will work on the other two buttons next.

Just trying to get my head around the scale function and how it uses the max value passed to it against setting the button width as a % or fill in the layout screen......

You will see the benefit of using a procedure with parameters when you encounter different upper limits for Fuel and Temp.

By the way, don't lose those length of list tests, you still need them just in case.