Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#13

AW: Zu wenig Arbeitsspeicher Fehler

  Alt 21. Feb 2014, 15:21
Und so sieht das dann in lesbar aus
Delphi-Quellcode:
procedure TForm1.FormCreate( Sender : TObject );
var
  LIni : TInifile;
  LCount : Integer;
begin
  LIni := TInifile.Create( 'C:\ProgramData\L-Write\crepesworker_user.ini' );
  try
    LCount := LIni.ReadInteger( 'Anzahl', 'Anzahl', 0 );
  finally
    LIni.Free;
  end;
  SetLength( FVorname, LCount );
  SetLength( FName, LCount );
  SetLength( FPin, LCount );
  SetLength( FBearb, LCount );
  GetList( LCount );
  Scrollbar1.Max := LCount;
end;

procedure TForm1.GetList( ACount : Integer );
var
  LIni : TInifile;
  LIdx : Integer;
  LUserSection : String;
begin
  LIni := TInifile.Create( 'C:\ProgramData\L-Write\crepesworker_user.ini' );
  try
    for LIdx := 0 to ACount - 1 do
    begin
      LUserSection := 'User' + IntToStr( LIdx );
      FVorname[LIdx] := LIni.ReadString( LUserSection, 'Vorname', 'Not_found' );
      FName[LIdx] := LIni.ReadString( LUserSection, 'Name', 'Not_found' );
      FPin[LIdx] := LIni.ReadInteger( LUserSection, 'Pin', 0 );
      FBearb[LIdx] := LIni.ReadBool( LUserSection, 'Bearb', true );
    end;
  finally
    LIni.Free
  end;
end;
und der Fehler wäre dir sofort ins Auge gefallen - nein, du hättest den erst nicht gemacht, weil es schon komisch aussieht
Delphi-Quellcode:
    for LIdx := 0 to ACount - 1 do
    begin
      LUserSection := 'User' + IntToStr( LIdx );
      FVorname[ACount] := LIni.ReadString( LUserSection, 'Vorname', 'Not_found' );
      FName[ACount] := LIni.ReadString( LUserSection, 'Name', 'Not_found' );
      FPin[ACount] := LIni.ReadInteger( LUserSection, 'Pin', 0 );
      FBearb[ACount] := LIni.ReadBool( LUserSection, 'Bearb', true );
    end;
Komisch, selbst bei diesem Code-Fragment weiß man sofort, welche Variablen lokal, welche die Argumente sind und welche zur Klasse gehören.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)

Geändert von Sir Rufo (21. Feb 2014 um 15:25 Uhr)
  Mit Zitat antworten Zitat