Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
How can I write if I want the GetAllVariables(callbackFn(object[])) function to retrieve the value in a variable called "vGetColor1"?
I have tried all sorts of things but I can not get anything to work.
The example in the API is like this:
Init = function() {
var mydoc = Qv.GetCurrentDocument();
mydoc.GetAllVariables(function(vars) {
for (var i = 0; i < vars.length; i++) {
var obj = vars;
var name = obj.name;
var value = obj.value;
}
});
}
This works good, and will loop through all variables in my document. I have tried to write an "IF (name = "vGetColor" ...) in there, but this value seems to exist only inside the function and I can't get it stored into a global JScript variable for some strange reason...
What I'm looking for is a function something like this:
function GetValueFromVariable(VariableName).
{
var mydoc = Qv.GetCurrentDocument();
return mydoc.GetAllVariables(function(vars) {
for (var i = 0; i < vars.length; i++) {
var obj = vars;
var name = obj.name;
var value = obj.value;
if (name==VariableName) return value;
}
};
However, this does not work. All I get back from my function is "Undefined"....
Please help me...
Regards Robert
I do not know what you are trying to achieve but if your variable name is fixed you could add a Text or RefValue to your extension by adding this line in your definition.xml :
<Text Initial="" Expression="=YourVariable" />
or
<RefValue Initial="" Expression="=YourVariable" />
Then you'll be able to retrieve your variable value in this.Layout.Text0.text or this.Layout.RefValue0.value.
I do not know what you are trying to achieve but if your variable name is fixed you could add a Text or RefValue to your extension by adding this line in your definition.xml :
<Text Initial="" Expression="=YourVariable" />
or
<RefValue Initial="" Expression="=YourVariable" />
Then you'll be able to retrieve your variable value in this.Layout.Text0.text or this.Layout.RefValue0.value.
Thanks, that works! /Robert