Go Down

Topic: hex or rgb from a MQTT message - Conversion or a better way (Read 4614 times) previous topic - next topic

PaulRB

These object oriented expressions can seem strange, when you first encounter them. A "String" with a capital S is a C++ object, or, more correctly, a class of objects. An object can contain both data and functions (called "methods").

The String object has methods called substring(), indexOf(), toInt() and many others. To call an object's method, you just write <object>.<method(x, y, z...)>

A method can return an object as it's result. For example, s1.substring(first, last) calls the method inside object s1 and returns a new String object, containing the part of s1 text between the two given positions. <first> and <last> are just numbers or expressions, so you can write a formula there. <last> is optional and if you omit that you get everything to the end of the string.

I have not tried this, but I think that toInt() takes as many digit characters as it finds, up to the first non-digit character it finds, and converts them to an integer. So you probably don't need to find the "," or ")" to tell toInt() where to stop.

eeze

Thanks for everything PaulRB!  Much appreciated!

Go Up