I've tried to run the following script in Sable but it did not work. I've got the error message "One of the commands on the button failed to execute. XCommand: Execute Script:JScript.test()". Would you please help me solve this problem? Thanks!
function test()
{
var rangeCount = GetNumberOfSubscriptRanges();
for (var i=0;i<rangeCount;i++){
var name = GetSubscriptRangeName(i);
name = name.replace(/"/g,'\'');
var elementCount = GetNumberOfSubscriptElements(name);
for(var j = 0;j<elementCount;j++){
var elementName = GetSubscriptElement(name,j);
elementName = elementName.replace(/"/g,'\'');
}
}
}
According to the manual of Microsoft Jscript (http://msdn.microsoft.com/en-us/library ... 90%29.aspx), name.replace(/"/g,'\''); replaces " by ', am i wrong?
By the way, i remove 2 lines with "replace" methods, it does not work either.
function test()
{
var rangeCount = GetNumberOfSubscriptRanges();
for (var i=0;i<rangeCount;i++)
{
var name = GetSubscriptRangeName(i);
name = name.replace(/"/g,'\'');
var elementCount = GetNumberOfSubscriptElements(name);
for(var j = 0;j<elementCount;j++)
{
var elementName = GetSubscriptElement(name,j);
elementName = elementName.replace(/"/g,'\'');
}
}
return 1;
}
It works like a charm in Sable Developer!
However, it does not work with Sable Runtime, i have the error
"Error: Microsoft JScript runtime error
Error executing : x= test()
Reason: expected object
Text:
Line:3"
What happens for you in Runtime? I click the button and the code executes correctly. The function you've written doesn't do anything that would show on the screen.