-
1. Re: CS3 JS progress bar function
[Jongware] Jul 5, 2009 11:21 PM (in response to John.Kordas)ScriptUI needs some time to get used to :-) A 'simple' progress bar was also my very first try and I think I made similar mistakes. But nothing to worry about.
The reason you get more than one window, of course, is this line in your function:
myWindow = new Window ..
(and subsequently myWindow.show();)
You should create the window (and usually, immediately show it) somewhere at the beginning of your script in an initialization phase. That'll pop up the window in the state you created it. Make the variable holding the window a global one, so you can access it even when using functions to 'drive' it.
In your update loop, you should only change the elements: myProgressBar.value, myStaticText.text, and myWindow.text. ScriptUI is smart enough to check if the elements are on screen, and changes them immediately.
Only when you are done processing, you call myWindow.close().
-
2. Re: CS3 JS progress bar function
John.Kordas Jul 6, 2009 7:10 PM (in response to [Jongware])Thanks Jongware I knew it had to be something simple.
Working version:
var myStop =6;
var myWindow = new Window ( 'window','Progress');
var myProgressBar = myWindow.add ('progressbar', [12, 12, 350, 24], 0, myStop);
var myStaticText = myWindow.add('statictext');
myStaticText.bounds = [0, 0, 340, 20];
myStaticText.alignment = "left";function stagesLeft(myText,stageVal){
if(stageVal == 1){
myWindow.show();
}
myProgressBar.value = stageVal;
myStaticText.text = myText;
myWindow.text = 'Stage '+ stageVal + ' out of ' + myStop;
if(stageVal == 6){
myWindow.close();
}
}To use the function:
stagesLeft("This is the first stage",1)
then further on in the script when another process is taking place
stagesLeft("Here is stage 2 of this script",2)
etc etc.
Cheers, John.


