I have a global variable defined in RM. I am trying to access in a custom app. I can't seem to find the correct syntax.
I tried myvar.getVariable(value), myvar.value.
Can someone point me in the right direction please.
I have a global variable defined in RM. I am trying to access in a custom app. I can't seem to find the correct syntax.
I tried myvar.getVariable(value), myvar.value.
Can someone point me in the right direction please.
Anyone got an answer here????
I have never tried this but I have seen info floating around about connectors, start here and I think you will find what you are looking for...
I’d read that and it didn’t help. Still can’t figure out how to access the value in an app.
Posting your question in that post might wake up people that already posted there and get a faster answer? Wish I could help more than that
The variable connector is just a device, and its value is just an attribute. You should be able to access it the same way that you access any attribute once you have a reference to the device. The attribute is called variable
, so:
myDevice.currentValue("variable")
or
myDevice.currentVariable
This assumes you have a reference to the device (technically a DeviceWrapper
), e.g., from an input
named myDevice
where the user selected the device, again the same as you'd have to do in any app for any device.
Neither of those work either. Just get an error of no signature of method.
I would suggest sharing the code that is not working for you, ideally an entire app in minimal-test-case form. The .currentValue("variable")
method works for me when called on a DeviceWrapper
pointing to the global variable connector, as I recently tested. Something else must be wrong, and no one can say what that could be without seeing more.
But because I can't resist guessing... Are you sure you have a DeviceWrapper
object here, e.g., that the variable you're calling currentValue()
on is the result of a user selection from an input
?
You may have something there. What did you use for the type or capability in preferences? I may be doing that wrong.
What selector you use doesn't matter; capability.sensor
is what I tested with, but I suppose device.RMConnectorVariable
(or however that needs to be formatted...) might be better since it scopes it to just the connector devices. But however you do it, as long as you're able to get the device selected, you have access to all its attributes and methods, even if it isn't part of the specified (selected) capability, so that shouldn't be the problem.
I was trying to use the wrong thing on the input. I changed it to capability.sensor and it worked.
Thanks for the help.
What. Is. This?!?
Finally a notation much more elegant than using currentValue(...)
!
But where are such treasures documented?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.