Ever wondered how you can create filenames by cycle.

Well, I did, because I needed it. And I came up with something that works and because once i forgot it, I decided this time to put it here. At least, I won't forget again :) If you have a better way to do it, please, say so.

The idea:

>A:=`/home/Data/file_`; B:=`.txt`;

>for i from 1 to 3 do C:=cat(A,i,B); writedata(`C`,[i],integer);od;

As simple as it is, it took me some time to figure it out.

And it's very useful if you have a cycle with a procedure that writes out long love messages in terminal, but you want to put it in command mode and read the output from a file later.

The above will write the meaningful value of i in a file with the corresponding name: /home/Data/file_i.txt.  The use of A,B and C is optional, of course, but this way it looks better to me. The short version is:

>for i from 1 to 3 do writedata(cat("/home/Data/file_",i,".txt"),[i],integer);od;

Please Wait...