Autor Beitrag
blackbirdXXX

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Mo 03.11.03 19:38 
Ich habe eine Ini Datei die u.A. Dateinamen auflistet
ausblenden Quelltext
1:
2:
3:
4:
[Filename]
filename_1 = datei.doc
filename_2 = datei2.doc
....

Ich habe mir das so gedacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var fname: Array of String;

procedure TForm1.LoadIni;
begin
 ini := TIniFile.Create(pdir + '\filelist.ini');
 max := ini.ReadInteger('Filname''Items'1);
 for i := 1 to max do fname[i] := ini.ReadString('Filename''File_' + IntToStr(i), 'na');
 ini.Free;
end;


Geht nur nicht. Wenn ich LoadIni aufrufe taucht:
Zitat:
Access violation at address 00404410 in module 'setup.exe'. Write of address 00000004.

auf.

Wenn ich aber
ausblenden Delphi-Quelltext
1:
var fname: Array[1..10000of String;					

eingebe funktioniert das. Wenn ich aber über 10000 Dateien habe ist das Array erschöpft. Gibt es da eine Lösung?

_________________
Klein, schwarz und ärgert Techniker? Jumper!
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mo 03.11.03 20:29 
Hallo,

Du musst dem Array schon mitteilen, wieviel Einträge es aufnehmen soll:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.LoadIni; 
begin 
 ini := TIniFile.Create(pdir + '\filelist.ini'); 
 max := ini.ReadInteger('Filname''Items'1);
 SetLength(fname, max); // <-- Anzahl der Einträge im Array
 for i := 1 to max do fname[i] := ini.ReadString('Filename''File_' + IntToStr(i), 'na'); 
 ini.Free; 
end;

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
blackbirdXXX Threadstarter

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Mo 03.11.03 20:45 
:( Dann bekomme ich überhaupt 3 Fehlermeldungen:
Zitat:
Access violation at address 00404436 in module 'setup.exe'. Read of address 00000186.


Zitat:
Exception EInvalidPointer in module setup.exe at 00002754.
Invalid pointer operation.


Zitat:
Runtime error 217 at 00402754

_________________
Klein, schwarz und ärgert Techniker? Jumper!
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mo 03.11.03 20:54 
Hallo,

Uups, hab' ich vorher nicht drangedacht: Der Index des Arrays beginnt mit 0, nicht mit 1. D.h., Du musst Deine Schleife entsprechend anpassen.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
blackbirdXXX Threadstarter

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Mo 03.11.03 21:30 
:D Ich zähle jetzt einfach am Ende 1 dazu und es geht. Danke fürs helfen.

_________________
Klein, schwarz und ärgert Techniker? Jumper!
barfuesser
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 324



BeitragVerfasst: Di 04.11.03 08:40 
ausblenden Delphi-Quelltext
1:
2:
FileList := TStringList.Create;
ini.ReadSectionValues('Filename', FileList);


FileList enthällt dann für jede Datei den entsprechenden Eintrag aus der Ini. Zugreifen auf die Dateinamen tust dann folgendermaßen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i:=0 to FileList.Count -1 do
begin
  FileName := FileList.Values[FileList.Names[i]];
end;


barfuesser