Login  Register

Re: Macro Language Issues

Posted by Volker Baecker on Apr 16, 2013; 9:36am
URL: http://imagej.273.s1.nabble.com/Macro-Language-Issues-tp5002660p5002662.html

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.html