Save & Load Sets?
Posted on 2004-03-29
I am trying to save & load a large amount of set data, to and from file using streams.
I have made an example of what I am trying to do.
It seams the writing to file works fine, but it crashes on the loading from file portion
Here is basically what I have:
TAnimal = (Dog, Cat, Horse, Cow, Squirrel);
TAnimals = set of TAnimal;
//returns the number of items in Set
function GetAnimalCount(AAnimals: TAnimals): Integer;
for AAnimal:= Low(AAnimal) to High(AANimal) do
if AAnimal in AAnimals then Result:= Result + 1;
Here is where I save to file
for Animal := Low(Animal) to High(Animal) do
if Animal in Animals then
WriteStreamStr(MemStr, GetEnumName(TypeInfo(TAnimal), Ord(Animal)));
here is where I load from file
for I:= 0 to Count - 1 do
Using a showmessage in teh load from file, i can show the first item read in, but then it crashes.