//Expects comma-separated species list on the clipboard //Example: Copy text fragment after '--begin--' and before '--end--' to the clipboard // then run the macro //02.01.19, 18:06 /* --begin-- *0, dummy *10, mac-0, Mackerel *11, mac-1 *12, mac-2 *13, mac-3 *14, mac-4 *15, mac-5 16, mac *20, hom-0, Horse Mackerel *21, hom-1 *22, hom-2 *23, hom-3 --end-- */ macro "Format Comma-separated List From Clipboard [1]"{ print("\\Clear"); txtIn = String.paste; if(indexOf(txtIn, '"')>=0) exit("Clipboard already contains quotes"); lines = split(txtIn, "\n\n"); txtOut = ""; for(jj = 0; jj < lines.length; jj++){ partsA = split(lines[jj], ", "); partsB = split(lines[jj], ",,"); if(partsA[0] == ""){ txtOut += thisLine + "\n"; continue; } if(partsB.length !=2 && partsB.length !=3) exit("2 or 3 comma-separated parts expected in line " + jj +": " + lines[jj]); thisLine = '+" '+ partsA[0] + ", " + partsA[1]; if (partsA.length > 2) thisLine += ", " + partsB[2]; thisLine = replace(thisLine, ";", ""); txtOut += thisLine + ';"\n'; } print(txtOut); selectWindow("Log"); }