Global variable trimming input


#1

1) Give a description of the problem
I have a global variable, that I am using to record the start of a particular operation. I am using $time24 to store into the variable that is up as a string.

2) What is the expected behaviour?

I would get the global variable as a four or five character long string. I.E 2137

*3) What is happening/not happening?

When I call the variable to place it into a text message, it is only coming back with the first two characters of the string. If I check inside the dashboard, it shows the variable as only being two characters long. Since I never specified a length and I see no way to limit it, I’m not sure why I’m only getting two characters.

Originally I was only using a local variable, and it was working fine giving me the result I expected. I needed a global variable so I could hand off the result from one piston to another.

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)


#2

A snapshot would help folks to give input.


#3

I think a snapshot of the piston and the logs would be helpful.

There are gotchas with global variables. They are read into a cache every time a new piston instance starts up and they are read from that cache for the lifetime of that instance. If your piston changes any global variables the changes are separately cached and only written out when the piston exits. So a piston doesn’t even see any changes it makes itself.


#4

Thanks for the responses.

@eibyer I did not include the code because I was having difficulty getting my phone to cooperate and not near my desktop. TBH I thought it was also kind of an easy fix I must be overlooking.

@orangebucket I discovered what you were saying early on and ended up with two pistons: One to react when the freezer temp gets too high, cause a virtual switch to flip, and save the start time to a global variable. The switch causes a while to come alive in another piston and send a text message every 7 minutes until the temp returns to normal. The global variable is part of the message to remind me how long ago this started. Not necessary but I wanted it to work the way I envisioned it.

FWIW at some point the issue with the time being truncated to the first two digits stopped and it is now operating as it should.

I appreciate your taking the time to respond.