Macro language question

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

Macro language question

Wolfgang Schechinger
Dear experts,

I would like to use the loop variable of a for...next construct as part of a filename, which should look like file[number].txt

How to achieve that? Is there something like the STR$(var) command from BASIC to convert numbers into strings?

Many thanks,

Wo


--
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx
Reply | Threaded
Open this post in threaded view
|

Re: Macro language question

lechristophe
Have a look at the macro language documentation, the function you're looking
for is d2s :

http://rsbweb.nih.gov/ij/developer/macro/functions.html#d2s

Christophe Leterrier

On Sun, Jun 8, 2008 at 23:08, Wolfgang Schechinger <[hidden email]> wrote:

> Dear experts,
>
> I would like to use the loop variable of a for...next construct as part of
> a filename, which should look like file[number].txt
>
> How to achieve that? Is there something like the STR$(var) command from
> BASIC to convert numbers into strings?
>
> Many thanks,
>
> Wo
>
>
> --
> GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
> Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx
>
Reply | Threaded
Open this post in threaded view
|

Re: Macro language question

Ben Tupper
In reply to this post by Wolfgang Schechinger
On Jun 8, 2008, at 5:08 PM, Wolfgang Schechinger wrote:

> Dear experts,
>
> I would like to use the loop variable of a for...next construct as  
> part of a filename, which should look like file[number].txt
>
> How to achieve that? Is there something like the STR$(var) command  
> from BASIC to convert numbers into strings?
>


Hi,

You should be able to direct "pasting" as ImageJ's interpreter will  
cast the number to string like this...

for (i=0; i<5 ;i++) {
        f = "myfile_" + i + ".txt";
        print(f);
}


But you can also use the macro function toString().  See ... http://
rsb.info.nih.gov/ij/developer/macro/functions.html#T

Cheers,
Ben



Ben Tupper
[hidden email]

I GoodSearch for Ashwood Waldorf School.

Raise money for your favorite charity or school just by searching the  
Internet with GoodSearch - www.goodsearch.com - powered by Yahoo!
Reply | Threaded
Open this post in threaded view
|

Antwort: Macro language question

Joachim Wesner
In reply to this post by Wolfgang Schechinger
Hi Wo,

as in Java, in a script the "+" operator is overloaded to concat strings
and numbers will automatically be converted to strings, so you can simply
do

for (i = 0; i < n; i++)  {    // Or similar
...

      name = "file"+i+".txt";

...
}

Cheers

Joachim


ImageJ Interest Group <[hidden email]> schrieb am 08.06.2008 23:08:14:

> Dear experts,
>
> I would like to use the loop variable of a for...next construct as
> part of a filename, which should look like file[number].txt
>
> How to achieve that? Is there something like the STR$(var) command
> from BASIC to convert numbers into strings?
>
> Many thanks,
>
> Wo
>
>
> --
> GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
> Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________