Printing values to the console

Post Reply New Topic
RELATED
PRODUCTS

Post

I am hoping this is an easy question to answer for someone.

I have spent a bit of time getting my head around the Javascript API and how everything works but one thing I can't work out is how to print values to the console so I can see what is being returned when I call a function.

For something like this in my script :

println(groove.getEnabled().value().displayedValue());

I get "RootControlSurfaceObject/GrooveProxy(Groove)/ParameterProxy/RangedValueProxy/ComputedStringValue/"

How do I convert this reference to the value so I can see what value is being returned?

Post

Look at the documentation of ComputedStringValue and Value in general. You either have to add an observer or use the get-method. If you use "get" you need to call markInteresed during intialisation.

Post

moss you legend!

That tip enabled me to fiddle around until I got the values printing. Now with the following code:

groove.getEnabled().value().addValueObserver(function(value)
{
if (value == 0)
{
println("match - " + groove.getEnabled().value().get());
}
else
{
println("no match - " + groove.getEnabled().value().get());
}
});
println(groove.getEnabled().value().get());

and clicking the groove button I get:

0
no match - 1
match - 0
no match - 1

I don't know why when I use groove.getEnabled().value().displayedValue() instead of groove.getEnabled().value() the console outputs a blank line instead of the formatted text value, and it doesn't respond to clicking the groove button:


match -


but at least I know how to look at values so that should give me some much needed feedback to push on.

Thanks a lot.

Post

Don't mix observers with getters. In the time of the callback the get-value might not be updated. And it is unecessary to call that function (and an overhead) when you already get the value as a parameter to the callback function.

Post Reply

Return to “Controller Scripting”