Wikia

Delphi Programming

Typed file

2,918pages on
this wiki
Talk0
type
  TDataType = extended;
  TDataTypeFile = file of TDataType;
procedure _write_data(var F: TDataTypeFile);
begin
  ptr_node:= ptr_list^.fNext;
  if ptr_node = nil then EXIT;
  repeat
    Write(F, ptr_node^.fData);
    ptr_node:= ptr_node^.fNext;
  until ptr_node = nil;
end;
Function TSplitList.SaveToFile(const FileName: string): boolean;
var
  f: TDataTypeFile;
begin
  result:= TRUE;
  AssignFile(F, FileName);
  try
    Rewrite(F);
    try
      _write_data(F);
    finally
      CloseFile(F)
    end;
  except
    result:= FALSE;
    raise EListError.Create(C_ERR_SAVE +UpperCase(FileName));
  end;
end;{ SaveToFile }
Procedure TSplitList.read_data(var F: TDataTypeFile);
begin
  try
    Read(F, tmp_dat);
    Clear(lst_splitter);
    Add(tmp_dat);
    repeat
      Read(F, tmp_dat);
      Add(tmp_dat);
    until EOF(F);
  except
    raise EListError.CreateFmt(C_ERR_READ, [FCOUNT -1]);
  end;
end;
Function TSplitList.LoadFromFile(const FileName: string): boolean;
var
  f: TDataTypeFile;
begin
  result:= TRUE;
  AssignFile(F, FileName);
  try
    Reset(F);
    try
      read_data(F);
    finally
      CloseFile(F)
    end;
  except
    result:= FALSE;
    raise EListError.Create(C_ERR_LOAD +UpperCase(FileName));
  end;
end;{ LoadFromFile }

--NNN nmanca 19:49, 13 August 2008 (UTC)

Around Wikia's network

Random Wiki