Jump to content
c4forums | The Control4 Community

Integer to string conversion

Recommended Posts

Help! Please tell me that Composer has an integer to string conversion routine somewhere or there is a smart way to do this...

I have created a number (8 at this stage) of numeric variables that I allow to move between 0 and 30 and they control delays on things like putting the house in holiday mode, turning off or on underfloor heating etc. I can increase and decrease the variables from my Touchscreen using the StartHere App. I want to use them for when I go on holiday. For instance, I can set (the relevant one) to 5 and this will turn the heating off after 5 days (if, say, my inlaws are going to use the house for the first 5 days), another one would be set to 20 to turn the heating back on after 20 days to get the house warm for our return the next day (I.e. After 3 weeks).

I have all the programming (including the use of the variables and increasing and decreasing the 8 variables via a page in StartHere) working perfectly, but I cannot display the variable's current value in StartHere because I need a text field not an integer field! The only way that I can see to do this involves 60 lines of code for each of the 8 variables... The first two lines of code would be:

If variable1 = 1 then

set text1 to "1"

There must be an easier way?

Link to comment
Share on other sites

You could write one start each one of the 8 then cut and paste and find replace in an xml editor.

Of course you would have made a backup of the project before embarking on that.

Sent from my LT26i using Tapatalk

And this is highly unrecommended

Sent from my iPhone using Tapatalk

Link to comment
Share on other sites

Sorry to harp on at this... I am resigned to the fact that this will not be easy but I am still looking for an easier way out. I have realised that I don't need to do this 8 times - once will work (in a macro using a dummy integer and a dummy string). I then pass the dummy integer a value before running the macro and use the dummy string as the ultimate output before running everything again (yes that is obvious but it took me all day to realise :-)).

I was then thinking that I could possibly cut down the code in the macro (and make this work more generically) if there is a way to combine strings... I.e. I could get the first digit into a string (string1) and the second digit into a string (string2). Without mods and ints etc. this would not be that simple but should be doable and could then be used for any number range...

But I suspect there is no way to combine strings. The solution I would then need is StingToUse = string1 + string2

So my comment for other users trying to do something similar is remember you can make this work by doing it once in a macro and my question for the gurus on this forum is: is there a way to combine strings in C4?

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...