Posted by
Jean-Philippe Grossier on
Apr 16, 2013; 9:35am
URL: http://imagej.273.s1.nabble.com/Macro-Language-Issues-tp5002660p5002661.html
hi,
no bug but:
Dialog.addChoice("Label", values, 2);
the default value 2 is not in your array, so it takes the first value of
your array. If you want 1000 as default:
values = newArray(10, 100, 1000);
Dialog.create("Test");
Dialog.addChoice("Label", values, 1000);
for your second point:
'+' as two meanings: either the mathematical operation or string
concatenation, depending on the first term. So if you have
value+something, it tries to sum and doesn't succeed to add a string to a
number.
when you do first a string+someting, it will convert to a string and
concatenate.
So the trick in your case is to do as in the second example, with an empty
string first, to say you want to concatenate
otherwise : return *toString(number)+" example";
*
cheers,*
*
jean-philippe Grossier*
*
2013/4/16 Louis Wolf <
[hidden email]>
> Hi,
>
> I'm running into a couple of issues with the macro language that seem to
> be bugs to me:
>
> 1) Dialog.addChoice("Label", array, default) doesn't set default value,
> but selects the first array item
>
> macro "Test" {
> values = newArray(10, 100, 1000);
>
> Dialog.create("Test");
> Dialog.addChoice("Label", values, 2); // 1000 expected,
> 10 given
> Dialog.show();
> }
>
>
> 2) Returning a string from a function doesn't always work:
>
> macro "Test" {
> print(returnStringBroken("broken"));
> print(returnStringWorking("working"));
>
> function returnStringBroken(value) {
> return value + " example"; //
> breaks: Number or numeric function expected
> }
>
> function returnStringWorking(value) {
> return "" + value + " example" ;
> // works
> }
> }
>
> Cheers,
> Louis
>
>
>
> Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het
> handelsregister onder nummer 41055629.
> The Radboud University Nijmegen Medical Centre is listed in the Commercial
> Register of the Chamber of Commerce under file number 41055629.
>
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html