Autor Beitrag
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 21:30 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
  MyFileList: TStringList;
begin
  MyFileList := TStringList.Create;
  try
    FindFiles('c:\...''*.wap', False, MyFileList);
    for i := 0 to MyFileList.Count - 1 do
    begin
      // Mach was mit der Datei MyFileList[i]
    end;
  finally
    MyFileList.Free;
  end;
Jetzt versuch aber einmal erst einmal selbst etwas damit... :roll:
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 21:45 
Also
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TForm1.FormShow(Sender: TObject);
begin
var
  MyFileList: TStringList;
begin
  MyFileList := TStringList.Create;
  try
    FindFiles( WPpath,'*.wap', False, MyFileList);
    for i := 0 to MyFileList.Count - 1 do
    begin
      // Mach was mit der Datei MyFileList[i]
      Dateiname[i] := MyFileList[i];
    end;
  finally
    MyFileList.Free;
  end;
end;

for i:=i++ do
  begin
  end

end;

Habe zwar nicht viel aber etwas verändert.

Dateiname : String;

Nur zum Verständnis für mich: Ich speichere jetzt die Dateinamen der Wegpunte in der Variable Dateiname oder ?

Jetzt muss ich ja "nur" noch die jeweilige Datei öffnen und die Werte, die ich haben will auslesen.

Hoffentlich hab ich das überhaupt richtig verstanden.
Grüße.

Moderiert von user profile iconNarses: Überflüssige Zeilenumbrüche/Leerzeilen entfernt.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 21:47 
user profile iconRobii hat folgendes geschrieben Zum zitierten Posting springen:
Nur zum Verständnis für mich:
Ich speichere jetzt die Dateinamen der Wegpunte
in der Variable Dateiname oder ?
Wozu? Du hast den Dateinamen doch in MyFileList[i]. :gruebel:
Das kannst du mit dem vorigen von mir geposteten Quelltext ja direkt kombinieren. Du musst eben statt dem Dateinamen dort nur MyFileList[i] benutzen...
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 21:54 
Stimmt ;)
Dann öffne ich jetzt einfach die Datei MyFileList[i] und suche mir meine Daten herraus.

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Zitat:
Stimmt ;)
Dann öffne ich jetzt einfach die Datei MyFileList[i] und suche mir meine Daten herraus.


Leichter gesagt als getan. Soweit bin ich jetzt gekommen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
  MyFileList := TStringList.Create;
  try
    FindFiles(WPpath, '*.wap', False, MyFileList);
    for i := 0 to MyFileList.Count - 1 do
    begin
      // Mach was mit der Datei MyFileList[i]
      AssignFile(MyFile, MyFileList[i]);

    end;
  finally
    MyFileList.Free;
  end;

Ich weiß aber nicht, wie ich jetzt genau die Werte aus der Datei lesen, die ich brauche?

Grüße.

Ps.: Aufjedenfall, glaube ich ( was ein Widerspruch ) hat das was mit ReadLn zu tun, oder?

Moderiert von user profile iconNarses: Überflüssige Zeilenumbrüche/Leerzeilen entfernt.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 22:06 
user profile iconRobii hat folgendes geschrieben Zum zitierten Posting springen:
Ich weiß aber nicht, wie ich jetzt genau die Werte aus der Datei lesen, die ich brauche?
Wie kommst du denn plötzlich auf AssignFile? :autsch:

Ich habe dir die Lösung doch schon gepostet... :roll:
www.delphi-forum.de/....php?p=564665#564665
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 22:20 
Entschuldige mich mein Meister ;]

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.FormShow(Sender: TObject);
begin
  MyFileList := TStringList.Create;
  try
    FindFiles(WPpath, '*.wap', False, MyFileList);
    for i := 0 to MyFileList.Count - 1 do
    begin
  FileContents := TStringList.Create;
  try
    FileContents.LoadFromFile(MyFileList[i]);
    X:=FileContents.Values['X'];
    Y:=FileContents.Values['Y'];
  finally
    FileContents.Free;
  end;

    end;
  finally
    MyFileList.Free;
  end;


Das ist jetzt mein Code.
Aber klappen tut er nicht, hab versucht X in nem EditFeld anzeigen zu lassen. Was ist noch falsch.
Zweifel langsam an mir selbst. Mano.

Grüße & danke für die GEduld
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 22:23 
Du hast vergessen die Variablen zu deklarieren oder die global deklariert. Zudem sind die Werte in Values Strings.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
procedure TForm1.FormShow(Sender: TObject);
var
  X, Y: Integer;

begin
  MyFileList := TStringList.Create;
  try
    FindFiles(WPpath, '*.wap', False, MyFileList);
    for i := 0 to MyFileList.Count - 1 do
    begin
      FileContents := TStringList.Create;
      try
        FileContents.LoadFromFile(MyFileList[i]);
        X := StrToInt(FileContents.Values['X']);
        Y := StrToInt(FileContents.Values['Y']);
        
        // Testweise:
        EditX.Text := IntToStr(X);
      finally
        FileContents.Free;
      end;
    end;
  finally
    MyFileList.Free;
  end;


user profile iconRobii hat folgendes geschrieben Zum zitierten Posting springen:
Aber klappen tut er nicht, hab versucht X in nem EditFeld anzeigen zu lassen. Was ist noch falsch.
Was klappt nicht? Und wo hast du das mit dem Editfeld versucht?
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 22:35 
Hatte X & Y als String global deklartiert. Und hab versucht X in einem Edit1.Text anzeigenzulassen.

Wenn ich das dann starte, wird in dem Textfeld einfach nichts angezeigt, startwert des Feldes ist aber 'X-Koordinaten', was darauf schliessen lässt, es zwar geändert wird, die Variable X aber nichts enthält..!

Ps.:
HIer hab ich es versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.FormShow(Sender: TObject);
begin
  MyFileList := TStringList.Create;
  try
    FindFiles(WPpath, '*.wap', False, MyFileList);
    for i := 0 to MyFileList.Count - 1 do
    begin
  FileContents := TStringList.Create;
  try
    FileContents.LoadFromFile(MyFileList[i]);
    X:=FileContents.Values['X'];
    Y:=FileContents.Values['Y'];
  finally
    FileContents.Free;
  end;

    end;
  finally
    MyFileList.Free;
  end;

Ma_Pos_Mes_Ed.Text := x;

Moderiert von user profile iconNarses: Überflüssige Zeilenumbrüche/Leerzeilen entfernt.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 22:39 
Hast du WPpath denn vorher zugewiesen?

Da musst du dann eben mal einen Haltepunkt setzen und zeilenweise durchgehen und schauen was passiert. Du kannst auch das Projekt (.dpr, .pas, .dfm) anhängen, dann kann ich kurz drüberschauen.
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 22:42 
Hab WPpath zugewiesen.
ausblenden Delphi-Quelltext
1:
WPpath := ExtractFilePath(Application.Exename);					


Eigentlich müsste es jetzt doch klappen.
Hab einen WP namens WPRobin123.wap im Ordner, wo ich auch das Projekt speichere.

Grüße

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 22:52 
Statt dein Projekt mal zu posten...
Im Anhang ein Projekt mit exakt dem Quelltext, das funktioniert problemlos. :roll:
Einloggen, um Attachments anzusehen!
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 23:10 
Hier Bitte,
1 zu 1 exakt kopiert

Grüße.


Ps: Die Waypoints sind als 'WAP'+Eingegebener NAme+'.wap' definiert.

Grüße.
Einloggen, um Attachments anzusehen!
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 23:14 
Und was klappt nicht? Mit meiner Testwap-Datei (siehe Testprojekt) klappt das Projekt direkt wie es ist. :nixweiss:
Im Edit erscheint die 100.

Vielleicht haben deine WAP-Dateien doch nicht das angegebene Format? Vergleiche einmal...
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 23:16 
Wirklich verstehen tu ich es nicht. Aber ich habe den Code aus deinem Beispiel genommen, ihn eingefügt und siehe da, es klappt.

Vielen Dank.
Jetzt ist mir einiges klarer geworden.

Eine Frage hätte ich noch. Wie kann ich per Befehl ein Bild erstellen? Also, das ich wenn ich dann x & Y koordinaten erstellt habe, ich ein Bild an diesem Punkt erstelle?

Grüße.

Moderiert von user profile iconNarses: Überflüssige Zeilenumbrüche/Leerzeilen entfernt.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 23:25 
Das kommt ja drauf an wie du es machen willst. Entweder sauber mit einer TPaintBox, die dann in OnPaint die Anzeige übernimmt, was aber schon ein wenig komplizierter ist.

Oder einfach indem du jeweils ein TImage erzeugst, an die richtige Position setzt und das Bild hineinlegst.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  MyImage: TImage;
begin
  MyImage := TImage.Create(Self);
  MyImage.Parent := Self;
  MyImage.Left := X;
  MyImage.Top := Y;
  MyImage.Height := ...
  MyImage.LoadFromFile... // oder aus einem mitgelieferten Bild aus einem anderen Image oder so.
  ...
Zudem: Neue Frage --> neues Thema
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 23:26 
Letzeres war genau das, was ich erwartet hatte.
Danke. Fals neue Probleme entstehen melde ich mich nochmal.

Vielen Dank !!

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Gleich eine Frage,
wenn ich in einem Frame mit einer Boolean-Variable arbeite, die ich auch in meinem Hautprogramm benutzte, wie kann ich sie für beide verfügbar machen?

Grüße.

Moderiert von user profile iconNarses: Überflüssige Zeilenumbrüche/Leerzeilen entfernt.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.05.09 23:52 
Du solltest das als Feld oder Eigenschaft deklarieren, dann kannst du vom anderen Formular aus drauf zugreifen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
TForm2 = class...
...
public
  MyField: Boolean;
end;

// im ersten Formular:

...
Form2.MyField := True;
Form2.Show;
...


Meinst du ein Formular, einen Frame oder noch etwas anderes? :mrgreen:

Und dass weitere Fragen nicht in den selben Thread gehören, weißt du doch... :roll:
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Sa 30.05.09 23:55 
E.:/ Hat sich geklärt.
Vielen Dank für die Geduld und die Erklärungen!
Jetzt bin ich wieder um Einiges schlauer!