Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Zu wenig Arbeitsspeicher Fehler (https://www.delphipraxis.net/179233-zu-wenig-arbeitsspeicher-fehler.html)

Luki206 21. Feb 2014 15:15

AW: Zu wenig Arbeitsspeicher Fehler
 
Ja, das mit der ini hatte ich auch gemerkt..

DeddyH 21. Feb 2014 15:17

AW: Zu wenig Arbeitsspeicher Fehler
 
Und damit sind alle Vorschläge über Bord geworfen. Ich bin gespannt, was Du machst, wenn Du mal eines Deiner Arrays sortieren willst.

Sir Rufo 21. Feb 2014 15:21

AW: Zu wenig Arbeitsspeicher Fehler
 
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.


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:33 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz