Txt-Unic name

From Vectorlab
Jump to: navigation, search


Function to create a create an unique name within the chosen environment: layers or not. Load the routines T_NameWillCollide and T_SplitNameFromNum before this. By Orso B. Schmid


{ Orso *********************************************** }
{ creates a unique name in NNA style "xxxxx-1" }
FUNCTION T_UnicName(inLayers: BOOLEAN; startName: STRING): STRING;
	VAR
		i, nr : INTEGER;
		proposedName, tempName : STRING;
		
	BEGIN
		proposedName := startName;
		
		WHILE T_NameWillCollide(inLayers, proposedName) DO BEGIN
			nr := T_SplitNameFromNum(proposedName); { this extracts the number from the name } 
			proposedName := concat(proposedName, -(nr + 1));
		END;
		
		T_UnicName := proposedName;
	END;