java for loop

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

java for loop

roberto aranibar
I am a fairly experienced Matlab programmer, but I have no experience with
Java and all I want to do is write a simple macro that does a for loop in it
which renames all the ROIs in my ROI manager as

"a{the number of the roi in the list (i.e., "13" if its the 13th roi in the
list)}n"

this is what I have so far, but the macros > evaluate line command in the
imageJ text editor says that my integer i is undefined:

for(int i=1;i=roiManager("count");i++) {
roiManager("Select",i-1);
roiManager("Rename","a"i"n");
}

I'm also unsure about the syntax used to insert the integer i into my
string.

Can anyone help or point me to a good reference? Thanks so much, Roberto

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Reply | Threaded
Open this post in threaded view
|

Antwort: java for loop

Joachim Wesner
Hi Roberto

some small points here:

You are talking Macro here it seems, Macro language is not really/fully
Java, superfluous to define variables at all in many cases, try

for(i=1;i<=roiManager("count");i++) {

You will also need <= not = for the comparison.

To build the name string, concat strings and numbers with "+"

roiManager("Rename","a"+i+"n");

Have you looked up the docs at

http://rsb.info.nih.gov/ij/developer/macro/macros.html ???

Hope this helps!



                                                                                                                                         
                      roberto aranibar                                                                                                  
                      <robertoaranibar@H         An:      [hidden email]                                                            
                      OTMAIL.COM>                Kopie:                                                                                  
                      Gesendet von:              Thema:   java for loop                                                                  
                      ImageJ Interest                                                                                                    
                      Group                                                                                                              
                      <[hidden email]                                                                                                
                      OV>                                                                                                                
                                                                                                                                         
                                                                                                                                         
                      23.06.2006 23:25                                                                                                  
                      Bitte antworten an                                                                                                
                      ImageJ Interest                                                                                                    
                      Group                                                                                                              
                                                                                                                                         




I am a fairly experienced Matlab programmer, but I have no experience with
Java and all I want to do is write a simple macro that does a for loop in
it
which renames all the ROIs in my ROI manager as

"a{the number of the roi in the list (i.e., "13" if its the 13th roi in the

list)}n"

this is what I have so far, but the macros > evaluate line command in the
imageJ text editor says that my integer i is undefined:

for(int i=1;i=roiManager("count");i++) {
roiManager("Select",i-1);
roiManager("Rename","a"i"n");
}

I'm also unsure about the syntax used to insert the integer i into my
string.

Can anyone help or point me to a good reference? Thanks so much, Roberto

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: java for loop

roberto aranibar
Thanks! that worked wonderfully. I had looked at the macro language
documentation, but I guess I didn't really understand the difference between
macro and java language. the concatenation thing I couldn't find anywhere
either. I've got a lot to learn, but thank you for giving me my first
lesson!

Roberto


>From: Joachim Wesner <[hidden email]>
>Reply-To: ImageJ Interest Group <[hidden email]>
>To: [hidden email]
>Subject: Antwort: java for loop
>Date: Sat, 24 Jun 2006 00:26:21 +0200
>
>Hi Roberto
>
>some small points here:
>
>You are talking Macro here it seems, Macro language is not really/fully
>Java, superfluous to define variables at all in many cases, try
>
>for(i=1;i<=roiManager("count");i++) {
>
>You will also need <= not = for the comparison.
>
>To build the name string, concat strings and numbers with "+"
>
>roiManager("Rename","a"+i+"n");
>
>Have you looked up the docs at
>
>http://rsb.info.nih.gov/ij/developer/macro/macros.html ???
>
>Hope this helps!
>
>
>
>
>                       roberto aranibar
>                       <robertoaranibar@H         An:      
>[hidden email]
>                       OTMAIL.COM>                Kopie:
>                       Gesendet von:              Thema:   java for loop
>                       ImageJ Interest
>                       Group
>                       <[hidden email]
>                       OV>
>
>
>                       23.06.2006 23:25
>                       Bitte antworten an
>                       ImageJ Interest
>                       Group
>
>
>
>
>
>I am a fairly experienced Matlab programmer, but I have no experience with
>Java and all I want to do is write a simple macro that does a for loop in
>it
>which renames all the ROIs in my ROI manager as
>
>"a{the number of the roi in the list (i.e., "13" if its the 13th roi in the
>
>list)}n"
>
>this is what I have so far, but the macros > evaluate line command in the
>imageJ text editor says that my integer i is undefined:
>
>for(int i=1;i=roiManager("count");i++) {
>roiManager("Select",i-1);
>roiManager("Rename","a"i"n");
>}
>
>I'm also unsure about the syntax used to insert the integer i into my
>string.
>
>Can anyone help or point me to a good reference? Thanks so much, Roberto
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today - it's FREE!
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
>
>______________________________________________________________________
>This email has been scanned by the MessageLabs Email Security System.
>For more information please visit http://www.messagelabs.com/email
>______________________________________________________________________

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/