Util-Resource find index by name

From Vectorlab
Jump to: navigation, search


Searches a list created by "BuildResourceList" for a given resource name. Returns the index if a matching resource is found. By Orso B. Schmid


{ Orso *********************************************** }
{ find a resource in a list created through BuildResourceList }
{ returns the index in the list or 0 }
FUNCTION U_FindInList(resN: STRING; list: LONGINT): INTEGER;
	VAR
		indx : INTEGER;
		tot : LONGINT;
	BEGIN
		U_FindInList := 0;
		
		IF Len(resN) > 0 THEN BEGIN
			tot := ResourceListSize(list);
			
			indx := 0;
			WHILE ((indx < tot) & (U_FindInList = 0)) DO BEGIN
				indx := indx + 1;
				
				IF GetNameFromResourceList(list, indx) = resN THEN
					U_FindInList := indx;
			END;
		END;
	END;