Posted by
GuyM on
Aug 04, 2015; 9:01pm
URL: http://imagej.273.s1.nabble.com/Array-of-strings-a-macro-question-tp5013893.html
Hello everyone,
I am writing a macro that will accept from the user string arguments, in order to sort files in one folder into different subfolders, based on differences in string occurrences in these file names (i.e. "...RedChannel..." vs "...BlueChannel..."). But I require some assistance with the following (displayed are only pieces of the code):
The user inputs the number of desired inputs/strings (manifested here below as "myString"):
for (j=0; j<MyString; j++) {
Dialog.addString("String "+j, title);
}
Dialog.show();
and then inputs the same number of strings to serve as future substring regexp and to construct the subfolders names:
for (j=0; j<MyString; j++) {
CurrentString= Dialog.getString();
StringArray=newArray(MyString);
FolderListPath=newArray(MyString);
StringArray[j]=CurrentString;
CurrentPath = path +CurrentString+ File.separator;
FolderListPath[j]=CurrentPath;
File.makeDirectory(CurrentPath);
}
But I noticed something strange: as the loop (the second one) proceeds, the arguments are passed ok one by one into the arrays. Once the loop terminates, the last row of the arrays are ok, but the rows above it are filled with zeros! I checked, and this also happens when numeric variables are being input instead of strings.
Any idea?
Thanks a lot in advance and all the best!
Guy
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html