Autor Beitrag
ConditionZero
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: Mi 27.12.06 17:05 
Moin,

nochmal ich ;)

Ich habe zwei variablen

ausblenden Delphi-Quelltext
1:
2:
path: String[255];
text: Textfile;


Und möchte die so anwenden:

ausblenden Delphi-Quelltext
1:
2:
assignfile(text,path + combobox1.text + '.txt');
reset(text);


Bekomm aber in beiden Zeilen die Fehlermeldung 'Inkompatible Typen'
Gibt es da eine möglichkeit zu konvertieren?

LG
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 27.12.06 17:10 
Geht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  s: String;
  text: Textfile;
begin
  AssignFile(text, s);
  Reset(text);
ConditionZero Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: Mi 27.12.06 17:15 
bei mir kommt da Inkompatible Typen ...
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Mi 27.12.06 17:24 
@Condition Zero
Also bei mir tut Luckies Code super.Zeig bitte mal den gesamten Code aus dem Ereignis. Wenn du nur sagst bei mir gehts nicht kommen wir nicht viel weiter ...

___________________
@Luckie, Hiho. bin grad bei dir in der nähe (Hannoversch. Münden), Oma besuch. Aber keine PAnik, ich komm nicht zu dir nach Kassel rüber :-)

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
ConditionZero Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: Mi 27.12.06 17:25 
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.Button1Click(Sender: TObject);
var
  path : string[255];
  i: String;

begin
  i := path + Combobox1.text + '.txt';
  path := extractfilepath(application.exename);
  path := IncludeTrailingBackslash(path);
  path := path + '\Fragen';
  if not directoryexists(path) then
    messagedlg('Es sind noch keine Fragen angelegt.', mterror, [mbcancel],0)
  else
  begin
    if combobox1.text = '' then
      exit
    else
    begin
      assignfile(text,i);
      reset(text);
      //dateibehandlung weiterführen
    end;
  end;
end;


;)
Andidreas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114

Windows XP Pro
BDS 2006
BeitragVerfasst: Mi 27.12.06 18:14 
Bei var text: TextFile vergessen.
Was soll das eigentlich werden:
ausblenden Delphi-Quelltext
1:
  i := path + Combobox1.text + '.txt';					


Leerer Pfad + ComboBox1.Text?
ConditionZero Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: Mi 27.12.06 18:20 
Ja da hatte ich nur was ausprobiert... Hab aber vergessen es wieder umzuädern bevor ichs hier rein gestellt hab


//Edit: die var text ist global deklariert also bei den public-deklarationen
KidPaddle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 351

WinXP,Linux
D7 Prof, XE7
BeitragVerfasst: Mi 27.12.06 19:31 
Es existiert innerhalb eines Formulares eine Property Text. Diese wird bei AssignFile verwendet und die ist nicht kompatibel mit dem Dateityp Text aus der Unit System. Verwende bei solchen Sachen nicht so allgemeine Begriffe, da solche "Fehler" immer extrem nervig sind.

Gruß
Thomas
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: Do 28.12.06 02:40 
user profile iconConditionZero hat folgendes geschrieben:
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.Button1Click(Sender: TObject);
var
  path : string[255];
  i: String;

begin
  i := path + Combobox1.text + '.txt';
  path := extractfilepath(application.exename);
  path := IncludeTrailingBackslash(path);
  path := path + '\Fragen';
  if not directoryexists(path) then
    messagedlg('Es sind noch keine Fragen angelegt.', mterror, [mbcancel],0)
  else
  begin
    if combobox1.text = '' then
      exit
    else
    begin
      assignfile(text,i);
      reset(text);
      //dateibehandlung weiterführen
    end;
  end;
end;


;)


Hallo,

es wird immer noch nicht funktionieren: wenn du schon IncludeTrailingBackslash aufrufst, darfst du nicht '\Fragen' anhängen, das ergibt path\\Fragen.

Gruss Reinhard
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Do 28.12.06 10:38 
Hey ConditionZero, ich glaube du ärgerst dich mit etwas rum, dem du nicht gewachsen bist. Willst du und vielleicht sagen, wie so der Inhalt einer Datei (die du öffnen willst) aussieht. Wahrscheinlich wäre es für dich viel einfacher du würdest das Problem mit einer TSTringList lösen.
MfG Fighter#1

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse