how to avoid macro interruption

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

how to avoid macro interruption

Mario Faretta
I am using a macro to open and analyse thousands of files in a directory.
Sometimes damaged files cannot be opened and this event cause the macro
interruption (due to the execption in the Open command). Unfortunately I am
not a Java programmer and I can only rely on macro language for programming
and at the moment I am not able to find a way to solve the problem. Is there a
way to intercept the execption in the open process skipping to the next item
to avoid macro abortion?
Thanks for the help
Mario

--
Mario Faretta
Department of Experimental Oncology
European Institute of Oncology
c/o IFOM-IEO Campus for Oncogenomics
via Adamello 16
20139 Milan
Italy
Phone: ++39-02574303054
email: [hidden email]
http://www.ifom-ieo-campus.it



[- Il Tuo 5 per Mille a favore della Ricerca dell'Istituto Europeo di
Oncologia

Tutti coloro che presentano il modello Unico, il modello 730 o più
semplicemente che ricevono dal proprio datore di lavoro il modello CUD, hanno
la facoltà di scegliere la destinazione del proprio 5 per mille.

Nella casella riservata al Finanziamento agli Enti della Ricerca Sanitaria
inserisci il codice fiscale dello IEO (08 69 14 40 153) ed apponi la Tua
firma.
Il Tuo 5 per Mille verrà destinato alla ricerca contro il cancro dell'Istituto
Europeo di Oncologia

NON COSTA NULLA E NON COMPORTA ALCUN AUMENTO DELLE IMPOSTE DA VERSARE
NON È UN'ALTERNATIVA ALL'8 PER MILLE
E' UN GESTO CONCRETO E DI GRANDE VALORE

Per saperne di più vai al sito dello IEO www.ieo.it < http://www.ieo.it >
oppure scrivi a [hidden email] < mailto:[hidden email]>

Segnala ad un amico questa opportunità

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

Re: how to avoid macro interruption

Wayne Rasband
 > I am using a macro to open and analyse thousands of files
 > in a directory. Sometimes damaged files cannot be opened
 > and this event cause the macro interruption (due to the
 > execption in the Open command). Unfortunately I am not a
 > Java programmer and I can only rely on macro language for
 > programming and at the moment I am not able to find a way
 > to solve the problem. Is there a way to intercept the
 > execption in the open process skipping to the next item to
 > avoid macro abortion? Thanks for the help

The ImageJ 1.43n daily build adds the IJ.redirectErrorMessages() macro
function, which prevents corrupted images opened using the open()
function from aborting the macro. This example, which measures all the
images in a folder, does not abort if the folder contains an image that
imageJ cannot open.

     requires("1.43n");
     dir = getDirectory("Choose a Directory ");
     list = getFileList(dir);
     setOption("display labels", true);
     setBatchMode(true);
     for (i=0; i<list.length; i++) {
         path = dir+list[i];
         showProgress(i, list.length);
         IJ.redirectErrorMessages();
         open(path);
         if (nImages>=1) {
             run("Measure");
             close();
         } else
             print("Error opening "+path);
     }

  I tested it by putting an MP3 file in the folder, which caused this
information to be displayed in the Log window:

    Opener: File is not in a supported format, a reader
    plugin is not available, or it was not found.
       /Users/Shared/Downloads/stack/test010.mp3
    Error opening /Wayne/Downloads/stack/test010.mp3

-wayne