MacroscriptLister - needs repair

Hi!

this is one of my favorite scripts, or was, since it crashes my Max 2014 nowadays.

Original credits: I dont remember :( I searched for the internet, but couldn't find where I found this script in the first place.
Great many thanks to the original author anyway. :)

macroScript MacroscriptLister
	category:"Haider"
	toolTip:"Macroscript Lister..."
	buttontext:"Macroscript Lister..."
 
(
	(
		rollout macroList "Macroscript List" (
			local mcrCategories;
			local mcrNames;
			local mcrTexts;
 
 
			dropdownlist categoryList;
			dropdownlist mcrNamesList;
			button runMcr "Run";
 
			on categoryList selected arg do (
				mcrNamesList.items = mcrTexts[arg];
			)
 
			on runMcr pressed do (
				--try (
					macros.run categoryList.selected mcrNames[categoryList.selection][mcrNamesList.selection];
				--) catch ()
			)
		)
 
 
 
		local mcrCategories	= #();
		local mcrNames			= #();
		local mcrTexts			= #();
		local mcrFiles			= #();
 
 
 
		local mcrStream = stringstream "";
		macros.list to:mcrStream;
 
 
 
		seek mcrStream 0;
		while (not (eof mcrStream)) do (
			local line = (readDelimitedString mcrStream "\n");
			local lineSplit = (filterString line "\"");
 
	 		local mcrName			= lineSplit[2];
	 		local mcrCategory		= lineSplit[6];
	 		local mcrFile			= lineSplit[8];
 
			local catIndex = (findItem mcrCategories mcrCategory);
			if (catIndex == 0) do (
				append mcrCategories mcrCategory;
				append mcrNames #();
				append mcrTexts #();
				append mcrFiles #();
				catIndex = mcrCategories.count;
			)
 
			append mcrNames[catIndex] mcrName;
			append mcrTexts[catIndex] mcrName;
			append mcrFiles[catIndex] mcrFile;		
		)
 
 
		local grinIndex = (findItem mcrCategories "Grin tools");
		if (grinIndex != 0) do (
			if (mcrFiles[grinIndex] != undefined) do (
				for i = 1 to mcrFiles[grinIndex].count do (
					local mcr = openFile mcrFiles[grinIndex][i];
					if (mcr != undefined) do (
						seek mcr 0;
						skipToString mcr "toolTip:";
						readDelimitedString mcr "\"";
						local newName = readDelimitedString mcr "\"";
						if (newName == "") do (
							seek mcr 0;
							skipToString mcr "buttonText:";
							readDelimitedString mcr "\"";
							newName = readDelimitedString mcr "\"";
						)
						if (newName != "") do mcrTexts[grinIndex][i] = newName;
					)
				)
			)
		)
 
		createdialog macroList width:400 style:#(#style_toolwindow, #style_sysmenu);	
		macroList.categoryList.items = mcrCategories;
		macroList.mcrNames = mcrNames;
		macroList.mcrTexts = mcrTexts;
 
		cui.RegisterDialogBar macroList;
	)
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Haider of Sweden's picture

.

Many thanks my friend. Works like a charm.

To make it even more useful, I added

button editMCR "Edit" width:100

and

on editMcr pressed do
(
macros.edit categoryList.selected mcrNames[categoryList.selection][mcrNamesList.selection]; 
)

There is a tiny bug of some sort.

When you run the script, you see the first category, but the dropdownlist mcrNamesList appears empty. You will have to pick the category again to make the mcrNamesList show something.
Can this be fixed?

Kind regards
Haider
www.haider.se

miauu's picture

.

macroScript MacroscriptLister
category:"Haider"
toolTip:"Macroscript Lister..."
buttontext:"Macroscript Lister..." 
(
 
	rollout macroList "Macroscript List" 
	(
		local mcrCategories;
		local mcrNames;
		local mcrTexts;
 
		dropdownlist categoryList;
		dropdownlist mcrNamesList;
		button runMcr "Run" width:100 across:3
		button editMCR "Edit" width:100
		button btn_refresh "Refresh" width:100
 
		function QuickSortByName subArr1 subArr2 =
		(
			local idx1 = subArr1[1]
			local idx2 = subArr2[1]
			case of 
			(
				(idx1 < idx2): (-1)
				(idx1 > idx2): (1)
				default:0
			)
		)
 
		function Reload =
		(
			local mcrCategoriesArr	= #();
			local mcrNamesArr			= #();
			local mcrTextsArr			= #();
			local mcrFilesArr			= #();
 
			local mcrStream = stringstream "";
			macros.list to:mcrStream;
 
			seek mcrStream 0;
			while (not (eof mcrStream)) do 
			(
				local line = (readDelimitedString mcrStream "\n");
				local lineSplit = (filterString line "\"");
 
				local mcrName			= lineSplit[2];
				local mcrCategory		= lineSplit[6];
				local mcrFile			= lineSplit[8];
 
				local catIndex = (findItem mcrCategoriesArr mcrCategory);
				if (catIndex == 0) do 
				(
					append mcrCategoriesArr mcrCategory;
					append mcrNamesArr #();
					append mcrTextsArr #();
					append mcrFilesArr #();
					catIndex = mcrCategoriesArr.count;
				)
 
				append mcrNamesArr[catIndex] mcrName;
				append mcrTextsArr[catIndex] mcrName;
				append mcrFilesArr[catIndex] mcrFile;		
			)
 
			local grinIndex = (findItem mcrCategoriesArr "Grin tools");
			if (grinIndex != 0) do 
			(
				if (mcrFilesArr[grinIndex] != undefined) do 
				(
					for i = 1 to mcrFilesArr[grinIndex].count do 
					(
						local mcr = openFile mcrFilesArr[grinIndex][i];
						if (mcr != undefined) do 
						(
							seek mcr 0;
							skipToString mcr "toolTip:";
							readDelimitedString mcr "\"";
							local newName = readDelimitedString mcr "\"";
							if (newName == "") do (
								seek mcr 0;
								skipToString mcr "buttonText:";
								readDelimitedString mcr "\"";
								newName = readDelimitedString mcr "\"";
							)
							if (newName != "") do mcrTextsArr[grinIndex][i] = newName;
						)
					)
				)
			)
			toSortArr = #()
			for i = 1 to mcrCategoriesArr.count do append toSortArr #(mcrCategoriesArr[i], mcrNamesArr[i], mcrTextsArr[i])
			qsort toSortArr QuickSortByName
			mcrCategoriesArr = #()
			mcrNamesArr = #()
			mcrTextsArr = #()
			for i = 1 to toSortArr.count do
			(
				append mcrCategoriesArr toSortArr[i][1]
				append mcrNamesArr toSortArr[i][2]
				append mcrTextsArr toSortArr[i][2]
			)
			categoryList.items = mcrCategoriesArr;
			mcrNames = mcrNamesArr;
			mcrTexts = mcrTextsArr;
			mcrNamesList.items = mcrTexts[1]
		)
 
		on categoryList selected arg do 
		(
			mcrNamesList.items = mcrTexts[arg];
		)
 
		on runMcr pressed do
		(
			macros.run categoryList.selected mcrNames[categoryList.selection][mcrNamesList.selection];
		)
 
		on editMcr pressed do
		(
			macros.edit categoryList.selected mcrNames[categoryList.selection][mcrNamesList.selection]; 
		)
 
		on macroList open do
		(
			Reload()
		)
	)
	createdialog macroList width:400 style:#(#style_toolwindow, #style_sysmenu);	
)
Haider of Sweden's picture

.

Thank you :)

Kind regards
Haider
www.haider.se

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.