Login  Register

Re: add/edit a comment and store it with an image?

Posted by vischer on Feb 15, 2011; 1:01am
URL: http://imagej.273.s1.nabble.com/add-edit-a-comment-and-store-it-with-an-image-tp3685672p3685676.html

In spite of Wayne's explanation I cannot get the following 3 macros to do this:

1. create an image with metadata "old text"
2. put "old text" into a text window so I can change it to "new text"
3. put "new text" back to the metadata.

The problem is that after the second macro, all menus disappear (OS X),
and the window is not editable either.

N. Vischer
----------


macro "Create Demo image [F1]"{
        newImage("A", "8-bit Ramp", 280, 250, 1);
        setMetadata("Info", "old text");
}

macro"Show Info [F2]"{
        info = getMetadata("Info");
        title1 = "Description";
        title2 = "["+title1+"]";
        f = title2;
        if (isOpen(title1)){
                selectWindow(title1);
                print(f, "\\Update:"); // clears the window
        }
        else
                run("Text Window...", "name="+title2);
        print(f, info);
}

macro "Store Info[F3]"{
        str = getInfo("window.contents");
        setMetadata("info", str);
}