I'm having a problem with a script component, and I think it might be a bug. I reproduced the problem with this simplified version:
if (true) {
int nTest = 1;
{
nTest = 5;
patExecContext.setProcessDataIntValue("/process_data/@nTest", nTest);
}
}
I think my process variable nTest should come out as 5, but I'm getting 1. The same problem happens with Strings.
Can someone reproduce this and let me know if I'm losing my mind here? Thanks.
Jared
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Jared,
I can reproduce the behaviour so your mind is ok.
The Custom Script service is a BeanShell implementation and off the top of my head I am not sure what BeanShell version it is. Apparently scoping has changed in BeanShell (see http://www.beanshell.org/manual/syntax.html).
This works...
boolean test = true;
int nTest;
if (test) {
nTest = 1;
{
nTest = 5;
patExecContext.setProcessDataIntValue("/process_data/@nTest", nTest);
}
}
Steve
Views
Replies
Total Likes
Hi Jared,
I can reproduce the behaviour so your mind is ok.
The Custom Script service is a BeanShell implementation and off the top of my head I am not sure what BeanShell version it is. Apparently scoping has changed in BeanShell (see http://www.beanshell.org/manual/syntax.html).
This works...
boolean test = true;
int nTest;
if (test) {
nTest = 1;
{
nTest = 5;
patExecContext.setProcessDataIntValue("/process_data/@nTest", nTest);
}
}
Steve
Views
Replies
Total Likes
Thanks for your response Steve. I've marked it as correct, since I think you're right in confirming that I have not lost my mind. It was informative to learn that the behaviour of the script object is not necessarily exactly as you would expect in a bona fide Java program, particularly where variable scope is concerned. In the case if the behaviour that I stumbled upon, I think it's a bug and not just a difference in the way beanshell handles variable scoping. I was able to find a work-around for the problem along the lines of what you discovered. It makes no sense, but it works. Thanks again.
Jared
Views
Replies
Total Likes
Jared;
If you believe that its a bug (and I'm not saying it is or it is not), then make sure it gets filed with Adobe Support. They can't fix it if they don't know about it.
Views
Replies
Total Likes
Done
Views
Replies
Total Likes
Views
Likes
Replies