1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69:
| procedure load_data(filename:string; var Voc_List:PTVoc); var f: TFileStream; i,k: integer; j:Byte; s:TStrings; zs:string; ZVL:PTVoc; begin Form1.Caption:='Personal Vocabulary Trainer - ' + copy(filename,1+length(PChar(ExtractFilePath(ParamStr(0)))),length(filename)-length(PChar(ExtractFilePath(ParamStr(0))))+1); f:=TFileStream.Create(filename,fmOpenRead); try f.Position:=0; ZVL:=nil; s:=TStringList.Create; while f.Position<f.Size do begin Voc_List:=nil; new(Voc_List); Voc_List.previous:=nil; Voc_List.next:=nil; f.Read(i,SizeOf(i)); f.Read(Voc_List.foreign,i); s.Clear; f.Read(j,SizeOf(j)); for k:=1 to j do begin f.Read(i,SizeOf(i)); f.Read(zs,i); s[k-1]:=zs; end; Voc_List.mother:=Create_Mother(s); f.Read(Voc_List.Last_Tested,SizeOf(TDateTime)); f.Read(Voc_List.Create_Date,SizeOf(TDateTime)); f.Read(Voc_List.Tested_Times,1); f.Read(Voc_List.Correct_Times,1); f.Read(Voc_List.Was_Last_Correct,SizeOf(boolean)); if ZVL<>nil then begin ZVL.next:=Voc_List; ZVL.next.previous:=ZVL; end; ZVL:=Voc_List; end; finally f.Free; end; end;
procedure save_data(filename:string;Voc_List:PTVoc); var f: TFileStream; i: integer; j:Byte; begin Form1.Caption:='Personal Vocabulary Trainer - ' + copy(filename,1+length(PChar(ExtractFilePath(ParamStr(0)))),length(filename)-length(PChar(ExtractFilePath(ParamStr(0))))+1); f:=TFileStream.Create(filename,fmCreate); Reset_Vocs(Voc_List); try while Voc_List<>nil do begin i:=length(Voc_List.foreign); f.Write(i,SizeOf(i)); f.Write(Voc_List.foreign,i); j:=Count_Mother(Voc_List.mother); f.Write(j,SizeOf(j)); while Voc_List.mother<>nil do begin i:=length(Voc_List.Mother.Meaning); f.Write(i,SizeOf(i)); f.Write(Voc_List.Mother.Meaning,i); Voc_List.mother:=Voc_List.mother.next; end; f.Write(Voc_List.Last_Tested,SizeOf(TDateTime)); f.Write(Voc_List.Create_Date,SizeOf(TDateTime)); f.Write(Voc_List.Tested_Times,1); f.Write(Voc_List.Correct_Times,1); f.Write(Voc_List.Was_Last_Correct,SizeOf(boolean)); Voc_List:=Voc_List.next; end; finally f.Free; end; end; |