Login  Register

How to work with return values in macro?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

How to work with return values in macro?

AAM71
46 posts
Hi All,

How to work with return values in macro? For example, File.delete(path) returns 1 if delete is successful. Then how I can get access to this return value?
Sorry for a stupid question.

Best regards,
Alex


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to work with return values in macro?

CARL Philippe (LBP)
466 posts
Dear Alex,
just do:
value = File.delete(path);
print(value);
That's it!
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

----- Mail original -----
De: "Aleksandr Mironov" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Jeudi 21 Janvier 2021 16:22:06
Objet: How to work with return values in macro?

Hi All,

How to work with return values in macro? For example, File.delete(path) returns 1 if delete is successful. Then how I can get access to this return value?
Sorry for a stupid question.

Best regards,
Alex


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to work with return values in macro?

Herbie
697 posts
In reply to this post by AAM71
Greetings Alex,

you could test if the operation was successful and decide what to do if yes
or no, e.g.

// ... some code ...
if ( File.delete(path) ) {
    // ... do something ...
} else
    exit("File could not be deleted.");
//

You may also ignore the return value.

HTH

Herbie

:::::::::::::::::::::::::::::::::::::::::::::::

AAM71 wrote

> Hi All,
>
> How to work with return values in macro? For example, File.delete(path)
> returns 1 if delete is successful. Then how I can get access to this
> return value?
> Sorry for a stupid question.
>
> Best regards,
> Alex
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html





--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html