Macro Help

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

Macro Help

NoobCoder
I am creating a macro to streamline a process for an experiment I am running. I want the macro to open a folder and get the list of all .TIF files then process them (Make binary + Analyze Particles). Then save the files as the file name + .txt in the folder.

I am not a coder, but I have been given this task, so I need your help. When I run my macro I receive a message stating "Undefined variable in line 2." Where am I going wrong?

---------------------------------------------------------------------------

getFileList("C:\\Documents and Settings\\barry\\Desktop\\Styler's stuff");
   for (i=0; i<list.length; i++)
   {
        if (endswith (list[i], ".TIF")
        {
                run("Make Binary");
                run("Analyze Particles...", "size=150-Infinity circularity=0.00-1.00 show=Outlines display clear include summarize record add");
                saveAs("Measurements", list[i]+ ".txt");
        }
}

---------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Macro Help

AJBell

Hi,

Not sure if this ever got answered, so appologies if it did, and if not, appologies for a late reply. The answer to your problem is that list.length is a variable, or rather the list part is.

alter your first line to list = getFileList(.....

or use any other variable, my preference is for single letters.

Hope this helps.

Andrew


<quote author="NoobCoder">
I am creating a macro to streamline a process for an experiment I am running. I want the macro to open a folder and get the list of all .TIF files then process them (Make binary + Analyze Particles). Then save the files as the file name + .txt in the folder.

I am not a coder, but I have been given this task, so I need your help. When I run my macro I receive a message stating "Undefined variable in line 2." Where am I going wrong?

---------------------------------------------------------------------------

getFileList("C:\\Documents and Settings\\barry\\Desktop\\Styler's stuff");
   for (i=0; i<list.length; i++)
   {
        if (endswith (list[i], ".TIF")
        {
                run("Make Binary");
                run("Analyze Particles...", "size=150-Infinity circularity=0.00-1.00 show=Outlines display clear include summarize record add");
                saveAs("Measurements", list[i]+ ".txt");
        }
}

---------------------------------------------------------------------------
</quote>