hi , guys.
I am a new learner studying XSI coding . currently I am going to do a custom UI for my own script which need PPG knowledge.
My script wrote like this
////////////////////////
var myPset=ActiveSceneRoot.AddProperty(“CustomProperty”,false,“Mytest”);
var myLayout=myPset.PPGLayout;
var b=1;
myLayout.AddRow()
myLayout.AddButton(“a”,“button”);
myLayout.Logic=a_OnClicked.toString();
myLayout.EndRow()
myLayout.Language = “JScript” ;
InspectObj(myPset);
function a_OnClicked(){
LogMessage(b);
}
/////////////////////
this is a very simple test coding , I dont know why my button function can not read variable “b” . very times when I run this script ,it always failed and show "b is not defined " .
I dont understand that I already defined var b=1 at the very beginning , how com the function can not visit it ?

Also, there’s a scripting subforum, moving the thread there for you, next time please post in the right section right away

As for the actual question, your variable b lives in the scope of the script you’re using to create the PPG. Once the PPG is created its own logic DOES NOT have that variable.
You need it in the logic of the command you’re implementing, or it needs to be passed as an argument for it to work.