Copy link to clipboard
Copied
How do you all test your resource spec script UI code? Every time I try to make a dialog with it, I get errors and have the hardest time troubleshooting. Any tips to make this easier?
Copy link to clipboard
Copied
I've used a clunky cheat to sorta help with debugging resource errors. I use a try/catch and process the err description to pull the error character out into an alert. Ideally there is a buffer of characters around the error character to help me hunt down the exact spot in the string. Doesn't always work, but usually gets me in the ballpark to find the error.
//START
try{
var myPanel = new Window("palette", "Name", undefined);
var res = "group{orientation:'row', aligment:['fill', 'fill'], alignChildren::['fill', 'fill'],\
test: StaticText{text:'Hi'},\
}";
myPanel.grp = myPanel.add(res);
myPanel.show();
}catch(err){
var desc = err.description //Calls the error description
var charOffsetLine = desc.split(",")[1]; //Splits at the commas
var offset = charOffsetLine.split(" "); //Grabs the second line of error text
var charLocation = offset[offset.length-1]; //Grabs what should be the numerical value of the error
var errSegment = res.substr(charLocation-20, 20); //Grabs characters before and after the error character
alert(errSegment); //Alert the results
}
//END
Copy link to clipboard
Copied
Thanks David. That's pretty helpful. I copied and pasted your code and was able to find and correct the errors based on the alert message. I'll try implementing this into my code. It would be awesome if there was a working ScriptUI WYSIWYG generator. I know there was one in the past but I never got it to work. So much time is wasted away for me when dealing with UI.
Copy link to clipboard
Copied
Thanks for that David. Nice idea.
Xavier.