Posted by
Louis Wolf on
Apr 16, 2013; 12:54pm
URL: http://imagej.273.s1.nabble.com/Macro-Language-Issues-tp5002660p5002668.html
Hi Volker, thanks for your reply.
> If I remember right the default in
> *Dialog.addChoice("Label", items, default)
> *is the default value not the index of the value in the list. So you
> should use 1000 instead of 2.
Nope, I don't think that is the problem. I've also tried entering the actual value in Dialog.addChoice. It is simply ignored, the first item shows up (I would actually expect an error if you put something in there that's not in the values array).
> In the second case the problem is not the returning of a string from a
> function. It is just the statement value + " example" that poses a
> problem. I think that if the interpreter reads a number first he
> interprets + as a numerical addition while when he reads a string first
> he interprets it as string concatenation.
It must be something like that, but not exactly. Because then it should work if "value" contains a string. But the example code I provide, which indeed contains a string, still breaks unfortunately. The code seems to interpret _every_ variable as a number.
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of Volker Baecker
Sent: Tuesday, April 16, 2013 11:36 AM
To:
[hidden email]
Subject: Re: Macro Language Issues
Hello,
If I remember right the default in
*Dialog.addChoice("Label", items, default)
*is the default value not the index of the value in the list. So you
should use 1000 instead of 2.
In the second case the problem is not the returning of a string from a
function. It is just the statement value + " example" that poses a
problem. I think that if the interpreter reads a number first he
interprets + as a numerical addition while when he reads a string first
he interprets it as string concatenation.
Volker
On 04/16/2013 10:43 AM, Louis Wolf wrote:
> 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.htmlHet 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