getting list of image windows or image id's in macro?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

getting list of image windows or image id's in macro?

Bill Christens-Barry
Is there a macro command allowing me to get a list of image windows, or a list of the id's of image
windows?

I'm also unsure how to get the number of open image windows or the largest (negative) image
window id. If I knew the largest (negative) id, I could loop isOpen(id) over all the id's and build a list
of image window titles or id's.

Thanks.

equipoise1
Reply | Threaded
Open this post in threaded view
|

Re: getting list of image windows or image id's in macro?

BenTupper
Hi,

On Mar 19, 2010, at 10:02 AM, Bill Christens-Barry wrote:

> Is there a macro command allowing me to get a list of image windows,  
> or a list of the id's of image
> windows?
>

You might try the following loop which relies on nImages (or  
nImages()) to tell you the number of open images...

names = newArray(nImages);
ids = newArray(nImages);
for (i=0; i < ids.length; i++){
        selectImage(i+1);
        ids[i] = getImageID();
        names[i] = getTitle();
        print(ids[i] + " = " + names[i]);
}

I guess it would be nice if selectImage returned the image ID or image  
name. I wonder if the selectImage command to have two optional  
arguments ...

selectImage(id, [id, name]);

or maybe return one and have an optional argument for the other.

id = selectImage(id, [name]);

... without breaking existing code.


Cheers,
Ben


> I'm also unsure how to get the number of open image windows or the  
> largest (negative) image
> window id. If I knew the largest (negative) id, I could loop  
> isOpen(id) over all the id's and build a list
> of image window titles or id's.
>
> Thanks.
>
> equipoise1