Changeset 4 for trunk/UAcronym.pas
- Timestamp:
- Apr 20, 2016, 11:11:26 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UAcronym.pas
r1 r4 42 42 TAcronymMeanings = class(TObjectList) 43 43 function SearchByName(Name: string): TAcronymMeaning; 44 function AddMeaning(Name: string): TAcronymMeaning; 44 45 end; 45 46 … … 48 49 TAcronyms = class(TObjectList) 49 50 function SearchByName(Name: string): TAcronym; 51 function AddAcronym(Name: string): TAcronym; 50 52 end; 51 53 … … 63 65 TAcronymContexts = class(TObjectList) 64 66 function SearchByName(Name: string): TAcronymContext; 67 function AddContext(Name: string): TAcronymContext; 68 end; 69 70 TAcronymEntry = class 71 Name: string; 72 Meaning: string; 65 73 end; 66 74 … … 76 84 procedure SaveToFile(FileName: string); 77 85 procedure FilterList(AName: string; Items: TAcronymMeanings); 86 procedure AddAcronym(AcronymName, MeaningName: string); 87 procedure RemoveAcronym(AcronymName, MeaningName: string); 78 88 end; 79 89 … … 92 102 end; 93 103 104 function TAcronymMeanings.AddMeaning(Name: string): TAcronymMeaning; 105 begin 106 Result := TAcronymMeaning.Create; 107 Result.Name := Name; 108 Add(Result); 109 end; 110 94 111 { TAcronymMeaning } 95 112 … … 117 134 end; 118 135 136 function TAcronyms.AddAcronym(Name: string): TAcronym; 137 begin 138 Result := TAcronym.Create; 139 Result.Name := Name; 140 Add(Result); 141 end; 142 119 143 { TAcronymContexts } 120 144 … … 127 151 if I < Count then Result := TAcronymContext(Items[I]) 128 152 else Result := nil; 153 end; 154 155 function TAcronymContexts.AddContext(Name: string): TAcronymContext; 156 begin 157 Result := TAcronymContext.Create; 158 Result.Name := Name; 159 Add(Result); 129 160 end; 130 161 … … 280 311 end; 281 312 313 procedure TAcronymDb.AddAcronym(AcronymName, MeaningName: string); 314 var 315 Acronym: TAcronym; 316 Meaning: TAcronymMeaning; 317 begin 318 Acronym := Acronyms.SearchByName(AcronymName); 319 if not Assigned(Acronym) then begin 320 Acronym := TAcronym.Create; 321 Acronym.Name := AcronymName; 322 Acronyms.Add(Acronym); 323 end; 324 Meaning := Acronym.Meanings.SearchByName(MeaningName); 325 if not Assigned(Meaning) then begin 326 Meaning := TAcronymMeaning.Create; 327 Meaning.Name := MeaningName; 328 Meaning.Acronym := Acronym; 329 Acronym.Meanings.Add(Meaning); 330 end; 331 end; 332 333 procedure TAcronymDb.RemoveAcronym(AcronymName, MeaningName: string); 334 var 335 Acronym: TAcronym; 336 Meaning: TAcronymMeaning; 337 begin 338 Acronym := Acronyms.SearchByName(AcronymName); 339 if Assigned(Acronym) then begin 340 Meaning := Acronym.Meanings.SearchByName(MeaningName); 341 if Assigned(Meaning) then begin 342 Acronym.Meanings.Remove(Meaning); 343 if Acronym.Meanings.Count = 0 then 344 Acronyms.Remove(Acronym); 345 end; 346 end; 347 end; 348 282 349 end. 283 350
Note:
See TracChangeset
for help on using the changeset viewer.