Dear IJ users,
I would like to build my results table in a way that would include couple of text columns (file name, date, time, camera name, etc). This didn't work since only the label column can include text. So I'm attempting to edit the results as text after saving the file but the text editing isn't macro-recordable or at least didn't record anything in my attempts. Could someone give me couple of hints on how to script text editing commands? Something like "find and replace" would be most useful. Best Regadrs, Maciej Rudzinski |
Hi Maciej,
you can get the contents of a 'Table' window (if it is the front window) by getInfo("window.contents"). If it isn't, use selectWindow(title) to bring it to the foreground. Then you can manipulate that String, e.g. with replace(string, old, new), and you may use 'print' to write it back. Restriction: a Table window has only one column; tab characters appear as spaces. title="my table"; quotedTitle = "["+title+"]" run("Table...", "name="+quotedTitle+" width=250 height=600"); print(quotedTitle, "this is text ..."); print(quotedTitle, "Note that the tab appears as a spaCe>\t<"); print(quotedTitle, "the 2nd row"); waitForUser("Change the table if you can (only deleting of lines possible)"); selectWindow(title); s=getInfo("window.contents"); s1=replace(s, "C", "c"); s2=replace(s1, "i", "I"); print(quotedTitle,"\\Clear"); print(quotedTitle,s2); For true text windows, printing "\\Clear" does not work, so you cannot modify its contents, only read it via s=getInfo("window.contents"); and append to it by 'print'. Michael ________________________________________________________________ On Apr 20, 2012, at 03:30, MR wrote: > Dear IJ users, > > I would like to build my results table in a way that would include couple of text columns (file name, date, time, camera name, etc). This didn't work since only the label column can include text. So I'm attempting to edit the results as text after saving the file but the text editing isn't macro-recordable or at least didn't record anything in my attempts. > > Could someone give me couple of hints on how to script text editing commands? Something like "find and replace" would be most useful. > > Best Regadrs, > > Maciej Rudzinski |
Hi Michael,
This is what i was looking for, a very simple edit and works great. Thank you so much for the hint and explanations. Best Regards, Maciej Rudzinski -----Original message----- From: Michael Schmid <[hidden email]> To: [hidden email] Sent: Fri, Apr 20, 2012 06:37:53 MST Subject: Re: Results Table edits Hi Maciej, you can get the contents of a 'Table' window (if it is the front window) by getInfo("window.contents"). If it isn't, use selectWindow(title) to bring it to the foreground. Then you can manipulate that String, e.g. with replace(string, old, new), and you may use 'print' to write it back. Restriction: a Table window has only one column; tab characters appear as spaces. title="my table"; quotedTitle = "["+title+"]" run("Table...", "name="+quotedTitle+" width=250 height=600"); print(quotedTitle, "this is text ..."); print(quotedTitle, "Note that the tab appears as a spaCe>\t print(quotedTitle, "the 2nd row"); waitForUser("Change the table if you can (only deleting of lines possible)"); selectWindow(title); s=getInfo("window.contents"); s1=replace(s, "C", "c"); s2=replace(s1, "i", "I"); print(quotedTitle,"\\Clear"); print(quotedTitle,s2); For true text windows, printing "\\Clear" does not work, so you cannot modify its contents, only read it via s=getInfo("window.contents"); and append to it by 'print'. Michael ________________________________________________________________ On Apr 20, 2012, at 03:30, MR wrote: > Dear IJ users, > > I would like to build my results table in a way that would include couple of text columns (file name, date, time, camera name, etc). This didn't work since only the label column can include text. So I'm attempting to edit the results as text after saving the file but the text editing isn't macro-recordable or at least didn't record anything in my attempts. > > Could someone give me couple of hints on how to script text editing commands? Something like "find and replace" would be most useful. > > Best Regadrs, > > Maciej Rudzinski |
Free forum by Nabble | Edit this page |