Code archives/Algorithms/ElementNaming
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This is a simple Naming process Hope it helps someone. this is good for avoiding duplicate names. I will add other extra functions for naming process in the future. | |||||
Function NamingProcess:String(WantedName:String, ListOfNames:TList) 'By Hardcoal Local Counter, NewName:String If WantedName = "" Then WantedName = "NewElement" NewName = WantedName Repeat If CheckNameExistence(NewName, ListOfNames) = False Then Return NewName Else Counter = Counter + 1 NewName = WantedName + " " + Counter End If Forever Function CheckNameExistence(Name:String, ListOfNames:TList) Local TempName:String For TempName = EachIn ListOfNames If LowerTrim(Name) = LowerTrim(TempName) Then Return True Next End Function Function LowerTrim:String(AString:String) Return Trim(Lower(AString)) End Function End Function |
Comments
None.
Code Archives Forum