How to determine the number of the active Analysis Window

I am trying to find number of active analysis window. The code below never creates variable activeWin even though I have one of the analysis windows activated.

Any help would be greatly appreciated, thanks.

AB = CreateObject( "Broker.Application" );
	Newa =  ab.analysisdocs;
	n=ab.activewindow;
	cnt=newa.count;
		
for( i = 0; i <= cnt; i++ ) 
{
	
			if(newa.item(i)==n)
			{
				activeWin=i;
			}
			
}type or paste code here

ActiveWindow is an active Chart window, not analysis window.

AmiBroker has multiple types of windows and documents each type having different collection of objects.

Thanks Tomasz, here is the corrected code

AB = CreateObject( "Broker.Application" );
	Newa =  ab.analysisdocs;
	n=ab.activeDocument;
	cnt=newa.count;
		
for( i = 0; i <= cnt; i++ ) 
{
	
			if(newa.item(i)==n)
			{
				activeWin=i;
			}
			

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.