macro "test create txt file"{ Dialog.create("untitled"); Dialog.addMessage("Choose Excel file that contains measurement data"); Dialog.show; raw_excel_path=File.openDialog("excel"); dummy_txt_file_path=replace(raw_excel_path,".","_")+".txt" vbs_path=replace(raw_excel_path,File.getName(raw_excel_path),"windows_instructions.vbs"); if(File.exists(vbs_path)==1) useless_result=File.delete(vbs_path); string_array=easy_load_string_func(raw_excel_path,dummy_txt_file_path); f=File.open(vbs_path); for(i=0;i", index); img_name_array[j]=tmp; index=index+lengthOf(img_name_array[j])+1; tmp=return_desired_substring(raw_txt_file,">","<",index); img_data_array[j]=tmp; index=index+lengthOf(img_data_array[j])+3; j=j+1; } print(img_name_array[6]); exit(); scale_and_convert_RGB_func(scale); read_array_and_draw_lines_funct(open_txt_as_string_array_funct(dummy_txt_file_path),scale,7); img_name=File.getName(img_path); Dialog.create("untitled"); Dialog.addMessage("CHOOSE DIRECTORY WHERE NEW FILE WILL BE SAVED"); Dialog.show(); new_img_path=getDirectory("Choose a Directory"); saveAs("jpeg",new_img_path+File.nameWithoutExtension+"_colored.txt"); selectWindow("Log"); run("Close"); run("Close"); } function easy_load_string_func(raw_excel_path,dummy_txt_file_path){ start_fin=rows_and_columns_dialog(raw_excel_path); colSize=start_fin[1]-start_fin[0]; sheetSize=start_fin[3]-start_fin[2]; //load "variables" here, then pass string through function... should just contain actual string values at macro-level array=newArray("Set objExcel = CreateObject(\"Excel.Application\") ", " Set objWorkbook = objExcel.Workbooks.Open _ ", " (\""+raw_excel_path+"\") ", " ", " ", " Set fs = CreateObject(\"Scripting.FileSystemObject\") ", " Set objTxt = fs.OpenTextFile(\""+dummy_txt_file_path+"\", 2,True) ", " ", " Dim my_array(1000,"+sheetSize+") ", " For a = 0 to "+sheetSize+" ", " i=0 ", " objTxt.WriteLine \"<\"+objExcel.worksheets(a+"+start_fin[2]+").Name+\">\" ", " While(objExcel.worksheets(a+"+start_fin[2]+").Cells(i+2,1).Value<>empty) ", " my_array(i,a)=\"\" ", " For j = 0 to "+colSize+" ", "my_array(i,a)=my_array(i,a)+CStr(objExcel.worksheets(a+"+start_fin[2]+").Cells(i+2,j+"+start_fin[0]+").Value)+vbTab", " Next ", " objTxt.WriteLine my_array(i,a) ", " i=i+1 ", " Wend ", " Next ", " ", " ", " objTxt.close ", " ", " objWorkbook.close ", " set objWorkbook=nothing ", " objExcel.Quit ", " set fs=nothing ", " set objExcel=nothing ", " set objTxt=nothing "); //end of string to be written to txt file. return array; } function rows_and_columns_dialog(excel_path){ array=newArray(4); Dialog.create("rows,columns,sheets"); Dialog.addMessage("Please start/end column and start/end worksheet \n from the excel file to be extracted. For multiple worksheets \n the columns must always be the same. *Note* Please use numbers only. \n Assumes labels are in Excel (ignores Row 1)"); Dialog.addNumber("Start Column",0); Dialog.addNumber("End Column",0); Dialog.addNumber("Start Sheet",0); Dialog.addNumber("End Sheet",0); exec("open",excel_path); Dialog.show; useless_result=exec("taskkill","/f","/im","excel.exe"); array[0]=Dialog.getNumber(); array[1]=Dialog.getNumber(); array[2]=Dialog.getNumber(); array[3]=Dialog.getNumber(); return array; } function return_desired_substring(string,sub1,sub2,index){ index_i = indexOf(string,sub1,index); index_f = indexOf(string,sub2,index_i); return substring(string,index_i+1,index_f); } function scale_and_convert_RGB_func(scale){ getDimensions(width,height,channels,slices,frames); run("Size...", "width="+width*scale+" height="+height*scale+" constrain average interpolation=Bicubic"); run("RGB Color"); } function read_array_and_draw_lines_funct(array,scale,columns) { for(j=0;j*columns+19LENGTH2) color_range=255*6*(abs(abs(sin(ANGLE1))-abs(cos(ANGLE1)))); else color_range=255*6*(abs(abs(sin(ANGLE2))-abs(cos(ANGLE2)))); color_region=floor(color_range/255); if(color_region==0){ R=255; G=0; B=255-color_range; }else if (color_region==1){ R=255; G=color_range-255; B=0; }else if(color_region==2){ R=255*3-color_range; G=255; B=0; }else if(color_region==3){ R=0; G=255; B=color_range-255*3; }else if(color_region==4){ R=0; G=255*5-color_range; B=255; }else if(color_region==5){ R=color_range-255*5; G=0; B=255; } print(color_range,color_region,R,G,B); setForegroundColor(R,G,B); setLineWidth(50*scale); drawLine(STARTX1,STARTY1,ENDX1,ENDY1); drawLine(STARTX2,STARTY2,ENDX2,ENDY2); } } -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html