Strange variable type for arrays filled from a dialog in macro language ?

Posted by lechristophe on
URL: http://imagej.273.s1.nabble.com/Strange-variable-type-for-arrays-filled-from-a-dialog-in-macro-language-tp3683053.html

Hi,

Please consider the following macro snippet:

Dialog.create("Dialog");
Dialog.addString("string 1", "1");
Dialog.addString("string 2", "2");
Dialog.addString("string 3", "No");
Dialog.show();
TEXT1=Dialog.getString();
TEXT2=Dialog.getString();
TEXT3=Dialog.getString();

ARRAY=newArray("1", "2", "No");
if (ARRAY[2]=="No") print("success");

ARRAYDIALOG=newArray(TEXT1, TEXT2, TEXT3);
if (ARRAYDIALOG[2]=="No") print("success");



ARRAY and ARRAYDIALOG should be exactly the same, containing three strings
"1", "2" and "No". ARRAY is directly defined, whereas ARRAYDIALOG is defined
via a dialog box that gets the user to enter strings. Just run the macro and
click "OK" in the Dialog, leaving the default text values. The test on
ARRAY[2] prints "success", but the second test for ARRAYDIALOG[2]=="No"
unexpectedly triggers the error "Number or numeric function expected".

I think this is a bug that has to do with the types of variables returned by
Dialog.getString(). Or am I confused ?

Christophe