Auto change label text color when the label text changes

824 views
Skip to first unread message

Ice Proz Inc.

unread,
Nov 1, 2017, 5:04:38 PM11/1/17
to MIT App Inventor Forum
Hello,
I created a Bluetooth temperature monitor that displays the temps of 6 separate Bluetooth connections.
The app works great to my wife's surprise.

Component list:
6 - ATmega328P chip, 6 - DS18B20 temp sensor, 6 - HC-05 BT module, 1 - Android tablet, MIT App Inventor 2, Arduino IDE.

I would like to have the label that displays the temp to auto change color to red when the temperature displayed goes above 41 deg F. I have the default label text color set to green by default.

Would one of you geniuses help me out?

Thanks for taking time to read this post.
The best way to reach me is via email at:
-Rob
20171030_161445.jpg

SteveJG

unread,
Nov 1, 2017, 6:00:48 PM11/1/17
to MIT App Inventor Forum
What you want to do is a simple concept.

We want you to have fun with App Inventor so here are some resources to help you learn to use the AI2 tools  A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  

How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

You need to use a conditional statement to make the color change.            Have you read this chapter in the online eBook  
If  temperatureLabel.text > 41 then temperatureLabel.Color = red  else temperatureLabel.color = black in the event handler that displays the label.

You need the blue Math blocks and the Color blocks.    Try some blocks.   If they work, congratulations.  If they do not, post them and someone will provide specific advice.
Exactly what you code depends on your existing blocks.

regards,
Steve

Ice Proz Inc.

unread,
Nov 1, 2017, 6:12:42 PM11/1/17
to MIT App Inventor Forum
Thanks for the reply,
I have been trying just what you mentioned
 using the clock and label for the first sensor
 and thought someone could show an example.

Thanks for you again for your post...
I will figure it out.
-Rob

TimAI2

unread,
Nov 2, 2017, 7:58:40 AM11/2/17
to MIT App Inventor Forum
Here is a simple example (see attached)

You will have to put the if statement in where the temperature data comes back
ConditionalColourChange.aia

Ice Proz Inc.

unread,
Nov 2, 2017, 12:39:37 PM11/2/17
to mitappinv...@googlegroups.com
TimAI2,
Thank you for the example. 
 I have been trying to place the argument in the clock that controls the BT data in.
 Is that where I should be?

Anywhere I try to place my code in the clock an error comes up when the app is launched.
"Bad arguments to > The operation cannot accept....."

The temp is being displayed in the label 8 as 41.00 and not 2 digits 41
Would that matter?
I have tried 41.00 in the code to no avail.
Also moved it around and tried it.
I have attached the aia that has the blocks only.
Would you take a look and see how bad I have messed it up?

Ice Proz Inc.

unread,
Nov 2, 2017, 5:05:31 PM11/2/17
to mitappinv...@googlegroups.com
Ok, I have the color changing on the tablet!!!

However when the app starts an error message appears and says:

Bad arguments to >
The operation > cannot accept the arguments.

Even with the error message I can see the app in the background and the color change of the label text in the code works perfectly.
It is something to do with the greater than symbol.
What can I do about the error message?
Another way to make the text change colors automatically?
I have attached the blocks for this argument.

Thanks for all of your help guys.
-Rob

TimAI2

unread,
Nov 2, 2017, 7:09:11 PM11/2/17
to MIT App Inventor Forum
Hi Rob

With only one block to go on, it is difficult to see if anything along with this code if causing the problem.

Your blocks:



Just to confirm, if you take these blocks out:

then everything works with no errors?


You could also try comparing text instead of numbers, just in case the text coming through is being seen as text and not a number (you can also test for this....



As my example shows there is nothing wrong with the blocks, so it must be to do with what is coming through, or something else is going on we can't see, maybe a timing issue?



Ice Proz Inc.

unread,
Nov 2, 2017, 7:29:06 PM11/2/17
to MIT App Inventor Forum
Thank you for the clear explanation.
Yes, the project works great.
I am just tweaking it to provide a more graphical view for the user.

I will use your example tomorrow morning.

May I ask how you are creating the block images?
They are great.

Thanks again,
-Rob

TimAI2

unread,
Nov 2, 2017, 7:35:33 PM11/2/17
to MIT App Inventor Forum
Block Images

You have options:

Just right click on any white space and "Download Blocks as an Image" (then edit / crop as needed in image editor)

Use your OS's Printscreen facility and then edit.

I run on Xubuntu Linux, and the screenshot facility offers "Select Region" so I can simply capture and area of blocks :)

Ice Proz Inc.

unread,
Nov 2, 2017, 7:49:59 PM11/2/17
to MIT App Inventor Forum
I thought there may have been something hot key style.
Thanks for the post!
-Rob

Ice Proz Inc.

unread,
Nov 3, 2017, 12:45:37 PM11/3/17
to mitappinv...@googlegroups.com

TimAI2, you are awesome!!!

The compare text function works GREAT! 

Not sure why the mathematical way wouldn't work.

I guess the label is actually not a number so the greater than symbol confuses Android 6.

I added a sound to the mix too! It works perfectly using the same function.

There is one problem,

5 of the labels display the color change and alarm sound perfectly.

The 5 that work are all set at 41 (cooler max temp) to make the change.

The one that isn't working correctly is for the freezer (Clock2), it is set at 32 (freezer max) to make the change.

I did see it work briefly but then It shows red and sets the alarm off.

Even when the temp displayed is well below the set point.

I replaced the label with a new one, tried moving it to different locations in the clock.

Checked the clocks to make sure they aren't firing at the same time.

Nothing I do seems to make the color change work correctly.

I've tried 56 different combinations test apps. UGG!

So I just set the label text to black in the design view and disabled the color change in the blocks for the freezer.

The temps that are displayed are all working fine, including the freezer.

I have attached the clocks if anyone wants to take a look...

TimAI2, you are the bomb!!!

Thank you, Thank you, and Thank you!

-Rob



TimAI2

unread,
Nov 3, 2017, 5:01:51 PM11/3/17
to MIT App Inventor Forum
Pleased you sorted the comparison part :)

Freezer, hmmm, negative numbers coming through? Maybe the text comparator treats a text with a "-" in front differently? ( it is NOT a number, from what you say)

Now most freezers should run at @ -23 degrees C which is -9.5 degrees F

(Nice blocks image ;) )   

Abraham Getzler

unread,
Nov 3, 2017, 5:15:17 PM11/3/17
to MIT App Inventor Forum
Text comparison of numbers can be tricky when they have a different number of digits.

Which is bigger, '9' or '10' ?

ABG

Ice Proz Inc.

unread,
Nov 3, 2017, 5:18:45 PM11/3/17
to MIT App Inventor Forum
TimAI2, I am using my freezer and it is in the single digits above freezing (usually 2 - 9), so negative numbers haven't been see yet.
Glad you mentioned that for a test after I work this problem out.
-Learned how to do block images from some dude,,, oh yea... you.
Thanks,
-Rob

Ice Proz Inc.

unread,
Nov 3, 2017, 5:31:37 PM11/3/17
to MIT App Inventor Forum
Hmm, with that thought I could change the argument to 41 and check it as all
double digits and that will rule out hardware issues.

I could also change the color change to a single digit as well.
Problem, if I lower the alarm to single digits it will change colors to early.
It needs to be 32 to allow temperature rise when the freezer is in defrost mode.

I kind of understand "Which is bigger, '9' or '10' ?".

I will change the argument to 5 and see how it works.

I built this entire project alone, hardware and software.
Wow guys, thank you for giving me the time of day.
Thanks again,
-Rob

Ice Proz Inc.

unread,
Nov 3, 2017, 8:49:20 PM11/3/17
to mitappinv...@googlegroups.com
It works great in the single digits.
ABG, You sly devil.
   :)

Ice Proz Inc.

unread,
Nov 3, 2017, 9:01:03 PM11/3/17
to MIT App Inventor Forum
I see you have ben where I am.
You are where I want to be...

Ice Proz Inc.

unread,
Nov 4, 2017, 3:26:59 PM11/4/17
to mitappinv...@googlegroups.com
I have tried using 4 digits in the compare text block (32.00)
 thinking that may help the color change when dealing
with 6.00 label text display. It did not help.
Clock 2 in the attached image.
Does anyone have an idea they could shoot my way?

Hint-Hint AGB??
Hint-Hint TinAI2???
Hint-Hint ???

Base 2???

Thanks for all of you guys input.

-Rob

Ice Proz Inc.

unread,
Nov 4, 2017, 3:48:38 PM11/4/17
to MIT App Inventor Forum
I there a way to force the incoming data to display in a label text as 4 digits?
Example:  07.35 instead of 7.35
I realize that when the label text displays negative numbers it will then use an extra space for the minus sign.
Example:  -07.35

-Rob

Taifun

unread,
Nov 4, 2017, 3:55:43 PM11/4/17
to MIT App Inventor Forum

SteveJG

unread,
Nov 4, 2017, 3:57:05 PM11/4/17
to MIT App Inventor Forum
Leading zeros?  Try Taifun's example  

Ice Proz Inc.

unread,
Nov 4, 2017, 4:32:36 PM11/4/17
to mitappinv...@googlegroups.com
Thank you for the link.
Question,
Is the minus sign in negative temperatures count as a digit too?

Lets say the freezer drops to negative digits,  -5.33 <<-- 4 digits?

So I will have to show 5 digits? -05.33 <<--5 digits?

So when it is not in the negative temperature it will show 005.32?

Or is 4 the max?

This is making my head hurt.
Going to get a beer, now this is getting serious.

-Rob

Taifun

unread,
Nov 4, 2017, 4:50:55 PM11/4/17
to MIT App Inventor Forum
as far as I can see, the procedure works only for positive values....
you might want to adjust it to your needs to accept also negative values...
after a beer you might be able to do it... ;-)
Taifun

TimAI2

unread,
Nov 4, 2017, 9:19:04 PM11/4/17
to MIT App Inventor Forum
Have you tried doing a conversion on the incoming bluetooth "text" number.

If it is incoming as for example "41.23" but AI2 is seeing it as text, try breaking it up into 5 pieces, then put it back together again in Ai2, but this time it should be a number

then you could use the original test on a number, and it would make handling negative numbers a bit easier, I could have a go at this in the morning......;)

TimAI2

unread,
Nov 4, 2017, 9:53:17 PM11/4/17
to MIT App Inventor Forum
It's morning now ;)

Bit of a sledgehammer to crack a nut, and probably a better coding route, but this seems to work


Take the "number" coming from bluetooth

trim to remove any excess characters either end

split characters into a list (the text box is blank)

test for a "-", take it out to build the number, then put it back if there is one, otherwise just rebuild the number

check it is a number

show it


Works for positive...


and negative numbers...




Ice Proz Inc.

unread,
Nov 5, 2017, 11:24:29 AM11/5/17
to MIT App Inventor Forum
Thanks TimAI2!
WOW, You are a coding geniuses!
I got a headache just reading that. :)

As I stare at the app running on the tablet I see the problem occurs before negative numbers are present.
Taifun suggested a way to add 0 to always have 2 digits present. 08.00 not 8.99.
I haven't had any luck incorporating it into my code.
(I'm not a guru like you guys)

The sensor I am using is the
 Dallas DS18B20, and the chip is ATmega328P-PU running at 8 MHZ.
The Dallas library may be able to send data in a different format.
08.99 and not 8.99
Do you think that may help any?
I don't even know if it is possible, I thought I would ask you if it
would even help before I investigated.
I think the app is getting confused on the 8.99 1 digits.

I need Advil!

-Rob


TimAI2

unread,
Nov 5, 2017, 11:52:58 AM11/5/17
to MIT App Inventor Forum
You should be able to put the blocks I did into a result procedure, feeding it with the incoming data from bluetooth.

Try it, see what happens, should overcome leading zeros etc. ??

May need some editing to match your code.... e.g. Button2.Click is your Clock.timer 2, label numbers and so on


Abraham Getzler

unread,
Nov 5, 2017, 12:25:05 PM11/5/17
to MIT App Inventor Forum
I'm glad you have returned from your weekend camping trip
in the Wilderness of Text, far from modern conveniences like
math libraries.

Working on removing extra wrappings around your numerical input
should help.  

See attached for a scrub() function that will return
a number from its input, with extraneous text stripped off.

That should facilitate numerical comparisons.

ABG

test_scrub.PNG
scrub.PNG
math.aia

Ice Proz Inc.

unread,
Nov 5, 2017, 3:18:19 PM11/5/17
to MIT App Inventor Forum
ABG,
I'm blown away,
Thank you for your input.
I will pick up tomorrow and try to wrap my block head around this.
-Rob

Ice Proz Inc.

unread,
Nov 5, 2017, 3:18:42 PM11/5/17
to MIT App Inventor Forum
TimAI2,
I will and thank you.
This simple thing turns out not so simple. (from my point of view).
I am so far over my head with all of this.

I would like to say Thank you to you and all that have attempted to pound
intelligence into my dumb a**.

Its 3 pm Sunday and I must spend time with my wife sometime this weekend.
So I will pick up tomorrow where I left off.

Ice Proz Inc.

unread,
Nov 8, 2017, 9:33:33 AM11/8/17
to mitappinv...@googlegroups.com

OK guys,

First I would like to say thank you for all of the help.

The 5 other sensors work perfectly due to the double digit temps being displayed.

Thanks TimAI2!

 

I still am having problems with the freezer temperature label color change.

I'm sure it is the single digit temperature being displayed that is the culprit.

 

I have stripped the program down to bare bones and have attached it.

 

I have used SteveJG's example for leading zeros and was able to display 2 digits with a leading zero.

However the same problem from the start of this post occurs. This example uses math and not text to do the operation.

As before this does not work. TimAI2 suggested using math to do the comparison and it worked great on the 5 listed above.

Is there a way to convert SteveJG example from math to text comparison?  07.99 Not 7.99

I am hoping that this fix the issue…

My apologies for the lack of knowledge in this area,

I am learning, just not fast enough!

-Rob

Abraham Getzler

unread,
Nov 8, 2017, 11:51:36 AM11/8/17
to MIT App Inventor Forum
You seem to be bending over backwards to do text math,
when you haven't dealt with the probability that the data 
is not arriving well from upstream.

Could you post your .ino file here?

ABG

Ice Proz Inc.

unread,
Nov 8, 2017, 12:45:13 PM11/8/17
to mitappinv...@googlegroups.com
I will,
What would make you think that would be a possibility?
I have no issues with displaying, un-readable, or operation of anything.
All I want to do is turn the text colors.
It works perfectly on 5 of the 6 sensors.
The only difference between then is the actual temperature being a single digit.
It is very clear after watching what happens that it is a problem in MIT with determining 1 and 2 digit data.

Remember your comment,

Text comparison of numbers can be tricky when they have a different number of digits.

Which is bigger, '9' or '10' ?

You know what...

Speaking in riddles is not what I am in the mood for.
You think it is cute, I do not.

Thank you for your comments.

I will try to figure this out without riddles.
Its very frustrating when a simple idea has to have so much discussion involved.
-Rob

Farzeen Harunani

unread,
Nov 8, 2017, 12:56:49 PM11/8/17
to MIT App Inventor Forum
I understand that everyone is trying and there are some communication issues, but please be kind to the power users. This an entirely volunteer effort on their part because our PU's love our users, and we love them. 

Ice Proz Inc.

unread,
Nov 8, 2017, 1:33:02 PM11/8/17
to MIT App Inventor Forum
Thank you for post.

I am being nice,,, and frustrated too.
 If I have offended anyone I apologize for that.
 I will leave this forum if requested to.

That being said, I would expect MIT App Inventor 2 to know that
 9.35 is less than 10.35 without having to do anything to the code.

I love the MAI2 concept, it is great.

After 34 posts to date we have worked out all but one issue.
 I thank you all for that.

Also, I understand that what is wanted maybe out of my reach.
Thank you again.
-Rob





Ice Proz Inc.

unread,
Nov 8, 2017, 1:35:51 PM11/8/17
to MIT App Inventor Forum
ABG,
If I have offended you apologize for that.
I say Thank you for all the people you have helped in this forum.

-Rob

Abraham Getzler

unread,
Nov 8, 2017, 1:57:00 PM11/8/17
to MIT App Inventor Forum
It's fine.

Would still like to see that .ino file, though.

ABG

Taifun

unread,
Nov 8, 2017, 1:59:52 PM11/8/17
to MIT App Inventor Forum
Text comparison of numbers can be tricky when they have a different number of digits.
That being said, I would expect MIT App Inventor 2 to know that
 9.35 is less than 10.35 without having to do anything to the code.

if you want to compare numbers, use the < or > block 
Taifun

Ice Proz Inc.

unread,
Nov 8, 2017, 2:04:28 PM11/8/17
to MIT App Inventor Forum
thank you

Ice Proz Inc.

unread,
Nov 8, 2017, 2:39:37 PM11/8/17
to mitappinv...@googlegroups.com
ABG,
Thank you for your help,
especially after the large tool I was to you!
:)

Just so we are on the same page,
The only problem I have to work out it when the freezer label text changes from 10.00 to 9.99 the label text changes from green to red.
Then as soon as the temp drops farther to negative numbers -0.01 it returns back to green.
It seems to count the - sign as a digit and answers the green argument.
That is why I thought if I was able to add a zero to the display when needed.
Take 0.01 and change it to 00.01 by adding the zero that may be a quick fix.

For the time being I have set the color of that one label text (freezer) to black.
The other 5 labels (coolers) work on the color change argument perfectly.
By using TimAI2 suggestion, and it works great! Thanks TimAI2!

I have also contacted someone about just changing the data being sent different from the sensor.
I was hoping not to have to do that, because of how smooth it all works.

I have attached the Arduino file you requested.

Thank you again,

-I'm a Tool



Abraham Getzler

unread,
Nov 8, 2017, 4:05:06 PM11/8/17
to MIT App Inventor Forum
I think I have the problem and the solution (See attached).
It is based on your fixme.aia export.

i see from your .ino file that you are sending every 5 seconds, using
a print() statement, so there is no Line feed character to delimit
one transmission from the next.

I see from your Clock2 attributes you check 1/second, so 
readings should not be piling up in the input buffer
and therefore not normally arriving bunched together.

I see in your Clock2.Timer blocks you were only taking input
if there were more than 1 byte waiting in the input buffer.
(Normally, the test is > 0, accepting even only 1 byte.)
This might be where you were getting burnt, around zero degrees.
When the temperature drops from  0 degrees then to -1 degree
the 0 would not arrive (because you deferred single byte messages)
until the -1 arrives, and all would be delivered together 
as 0-1 (an illegal number).

I applied my fixes to Clock2.Timer in the attached .aia file,
and leave it to you to test it, since I have no hardware.

ABG
.

Clock2_Timer.PNG
temperature_ino.PNG
Clock2.PNG
fix_me_ABG.aia

Abraham Getzler

unread,
Nov 8, 2017, 4:31:50 PM11/8/17
to MIT App Inventor Forum
P.S.  The testing numberofbytes > 1 should also cause single digit
temperatures to arrive in pairs, so if the temperature were 9
degrees then 8 degrees, '98' would arrive.
ABG
Message has been deleted

Ice Proz Inc.

unread,
Nov 8, 2017, 4:48:06 PM11/8/17
to MIT App Inventor Forum
At the beginning of this post, using numeric was the initial attempt.
The label text would complied but when launched an error shows stating the argument was accepted.
So, TimAI2 made a suggestion to use the text compare and it worked great accept for the freezer.
I have tried what you suggested quite sometime back, and will try again.
I will set clock to zero.
thanks,
-Rob

Ice Proz Inc.

unread,
Nov 8, 2017, 4:49:08 PM11/8/17
to MIT App Inventor Forum
I tried it out of desperation...
:)

Ice Proz Inc.

unread,
Nov 8, 2017, 4:56:26 PM11/8/17
to MIT App Inventor Forum
Note, the temperature is always displayed correctly.
negative or positive.
The only problem is the color change
-Rob

Abraham Getzler

unread,
Nov 8, 2017, 5:11:37 PM11/8/17
to MIT App Inventor Forum
Regarding the color change, 
the Designer lets you rename components,
and the Blocks Editor adjusts automatically.

If you were to rename Label2 to lblTemperature,
that might help detect any switched label numbers.

Post your new Downloaded Blocks Image for more ideas.

Also, consider changing the label background color
instead of the text color, if it will help visibility.

Regarding the 6 clocks,  this could all be done in one clock
if you move all the other clock timer contents into clock1,
back to back.  That would rule out any clock interactions.

ABG

Ice Proz Inc.

unread,
Nov 8, 2017, 5:58:35 PM11/8/17
to MIT App Inventor Forum
All on one clock and set Bluetooth connect to 0.

My wife is hanging out more that usual, have to go for the evening.
thanks for your help and again apologies.
-Rob

Ice Proz Inc.

unread,
Nov 13, 2017, 12:17:21 PM11/13/17
to mitappinv...@googlegroups.com

Hi TimAI2,

First, thanks for all your help.

This app displays all the temps perfectly (freezer and coolers) at all times.

I just thought it would be nice to have the text change color but, not necessary.

 

I have attached the .aia file and image.

 

Working off of your recommendations, the color changes perfectly until single digits are displayed.

The only way the app will load without errors is by using the “red” compare text argument and it works great as long as single digits are in play.

 

When the “blue” math argument is used an error occurs when app is launched.

“The operation cannot accept the argument”.

 

I tried to use your sledgehammer example and could not get it to work (way past my current abilities).

I also tried to using Taifun’s example for adding zeros and started to get the same errors as above.

 

There are the several different ways that I have tried.

4 ways are in the blocks.

2 of the ways cause an error when the app starts.

2 of the ways cause no error when the app starts and works until single digits.

All noted in the aia.
I apologize for my programming short comings.
I have searched for any MI2 color change and have not found anything remotely close to what I am trying to do.
I didn't want to leave this group post open so,
I'm thinking maybe this is not in my grasp and may just give up on the color change idea and mark it done.
Any thoughts?

Thanks again,
-Rob

Abraham Getzler

unread,
Nov 13, 2017, 2:00:03 PM11/13/17
to MIT App Inventor Forum
I think I have the cause and a solution.

Your Clock Timer is set to run in the Designer,
which is like ordering your fireworks from the factory pre-lit.

You are comparing your label.Text fields against numeric temp values,
but when you start you initialize the temperature label.Texts to
"Not Connected", which will fail any numeric comparison.

I suggest using blue 999 (instead of Not Connected) as your starting values for temperature .Text
fields, to not blow up the comparisons.

Use some other way to announce connected/not connected.

ABG





Ice Proz Inc.

unread,
Nov 14, 2017, 11:09:45 AM11/14/17
to MIT App Inventor Forum

Nice thoughts ABG,

 

However the not connected text label could not be the problem because I have stripped down versions that I am working with that have only the Bluetooth connect call and nothing else in the function (No label text in the code). The problem is still present.

 

To be clear, the not connected reference is not in many of the builds that I use and the problem is still present.

I just happened to be working on the build at the time that has the not connected label text when I made the post. 

 

The not connected labels are only called on if the connection was not made to the Bluetooth device that was specified, there is no event called when the connection has been made. Also, the text in the designer is set blank.

 

The clock timer runs from the start, and is set to fire at one second intervals.

Should I change the way it is initialized? If so please explain how if change it would work to cure the color change issue.

 

I really think the problem lies in the interpretation of the single digits temperature that displays when the temperature drops from 10.00 to 9.99.

Reason: The temp color change works great until this and only this event takes place.

 

To test my theory I have been trying to add a zero, break apart the data and rebuild it, and many other ideas that have been brought to my attention in this forum. I just do not have the coding skills to make any of them work without getting argument errors when the app is started (thank you to all that have blesses with your ideas).

 

 

Thanks ABG,

-Rob

Abraham Getzler

unread,
Nov 14, 2017, 12:19:13 PM11/14/17
to MIT App Inventor Forum
getting argument errors when the app is started

This is the key.

Check Designer starting values in anything you use
for numeric comparison.  Make sure they start out numeric.

ABG
 
Message has been deleted
Message has been deleted

Ice Proz Inc.

unread,
Nov 16, 2017, 3:24:22 PM11/16/17
to MIT App Inventor Forum
Okay guys,
I want to say thank you for the posts and code that all of you have taken time to do.
I don't usually give up on anything but,,, I have to move on and leave this as unsolved for the time being.
Thanks to you all again,
-Rob

Ghica

unread,
Nov 17, 2017, 9:43:29 AM11/17/17
to MIT App Inventor Forum
Maybe you can attach your latest .aia and let us look for a SOLUTION?
It still sounds awfully simple to solve, and probably Abraham was right about initial values.
Cheers, Ghica.

Ice Proz Inc.

unread,
Nov 22, 2017, 4:39:35 PM11/22/17
to MIT App Inventor Forum
Thank you for your post.
I am un-clear how to "Check Designer starting values".
Please explain.
-Rob

Ice Proz Inc.

unread,
Nov 22, 2017, 4:53:55 PM11/22/17
to MIT App Inventor Forum

Ice Proz Inc.

unread,
Nov 22, 2017, 5:05:31 PM11/22/17
to mitappinv...@googlegroups.com
I have 4 sets of arguments in the attached aia that I have been playing with.
2 of them have the color change working and 2 do not.
Unfortunately the ones that work, give an argument error when the app starts.

Error that shows when the app starts.
"Bad arguments to >
The operation cannot accept the argument." [41]

Using the back button on the error message leaves me with a perfectly working app.
I have added notes to the arguments for details.

Need to figure out how to get rid of the error when the app starts and we are good to go.



---

apk file removed, see the Posting Guidelines.
Taifun



blocks.png

Abraham Getzler

unread,
Nov 22, 2017, 6:03:42 PM11/22/17
to MIT App Inventor Forum
Put a 0 in the label,
see attached arrow.

ABG

Capture.PNG

Ice Proz Inc.

unread,
Nov 22, 2017, 6:23:33 PM11/22/17
to MIT App Inventor Forum
I have tried all of these in the past, when you mentioned it
 before thinking that maybe what you were referencing.
I have just tested again:
0
00
00.00
in the label designer.
Still get the error:

Bad arguments to >
The operation > cannot accept the arguments.

If I hit the back button to get rid of the error message,
The app color change works great.
I don't understand if there is an error, how does it work?
All I know when I back off the error the app works perfect.

Pesky error!

-Rob

Ghica

unread,
Nov 23, 2017, 4:34:06 AM11/23/17
to MIT App Inventor Forum
As the error states, the problem MUST be that you have a non-numeric value in the text of Label1. 
Do this to find out and to prevent the error:


Probably your BT device sends something non-numeric in the beginning and this way you can find out what it is and prevent error messages. If you take out the notifier later, you just ignore those non numeric values.
Cheers, Ghica.

Ice Proz Inc.

unread,
Nov 23, 2017, 7:38:39 AM11/23/17
to MIT App Inventor Forum
Thank you for the post.
I am tiring it now!
-Rob
Message has been deleted

Ice Proz Inc.

unread,
Nov 23, 2017, 12:14:00 PM11/23/17
to MIT App Inventor Forum

OMG!!! WOW!!!

That was the trick!!!

What a Thanksgiving!!!

 

I think,

the Bluetooth module transmits a decimal point or something unseen in the data that is not considered a number.

Thus confusing the comparison.

 

Thank you all for the continued support!

 

Thank you, Thank you, Thank you!!!

Complete and solved!!!

 

 

-Rob

 

I now am going to add a too cold text color change to the coolers and set it at

 

label1.text < 32

label1.text.color = Red

 

Should I mark this as solved and create a new thread or continue in this thread?

Ghica

unread,
Nov 23, 2017, 12:45:52 PM11/23/17
to MIT App Inventor Forum
If you ask about another problem, then start a new thread. 
If you want to continue with this problem, for some reason, stay here.

Do not forget the test for non-numeric for the too cold. You never know.
Cgheers, Ghica.

Ice Proz Inc.

unread,
Nov 23, 2017, 12:58:01 PM11/23/17
to MIT App Inventor Forum
Thank you again,
It is the same project and is still dealing with color change of text so,
I think I'll keep it here.

-Rob

Abraham Getzler

unread,
Nov 23, 2017, 2:56:06 PM11/23/17
to MIT App Inventor Forum
You might not yet be out of the woods on that decimal point.

Be careful you don't receive two consecutive fractional readings in one
BlueTooth read, back to back.  Having two decimal points in one number
would be a problem.

This would happen if you are asking for all the incoming data 
that might have arrived, and you are  not checking much more frequently than
the data is arriving.

Having your AI2 Clock twice as fast as your transmitting
device should be a safe margin.

ABG


Ghica

unread,
Nov 23, 2017, 3:59:00 PM11/23/17
to MIT App Inventor Forum
Or send proper delimiters from your device that you can test on.
Cheers, Ghica.

Ice Proz Inc.

unread,
Nov 24, 2017, 8:54:48 AM11/24/17
to MIT App Inventor Forum
Thanks ABG,
I have the clock set to fire at one second intervals and new data coming in every five seconds.
Seems to be okay as you predicted.
Lucy is too funny.

-Rob
Reply all
Reply to author
Forward
0 new messages