Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Incompatible types: 'String' and 'TStrings' (https://www.delphipraxis.net/7512-incompatible-types-string-tstrings.html)

quakergod 14. Aug 2003 14:42


Incompatible types: 'String' and 'TStrings'
 
hallo :)
hab ein dummes problem :oops:

ich hab ein script gefunden das eine http txt datei in ein memo lädt, das möchte ich dazu nutzen die aktuellste programm version anzuzeigen, nur ich möchte die version in einem label und nicht in einem memo feld anzeigen lassen!

hier das script:

Delphi-Quellcode:
function download(url, pfad:string): Boolean;
begin
  Result := UrlDownloadToFile(nil, PChar(url), PChar(pfad), 0, nil) = 0;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
label4.Caption := memo1.lines;
  if download('http://www.server.net/version.txt',ExtractFilePath(Paramstr(0)) + 'datei.txt') then begin
  memo1.lines.loadfromfile(ExtractFilePath(Paramstr(0)) + 'datei.txt');
end
else ShowMessage('Fehler beim Download!');
end;
wenn ich "label4.Caption := memo1.lines;" in FormCreate mache, sagt er immer:

[Error] Incompatible types: 'String' and 'TStrings'

Wie mache ich das jetzt ? :lol:

[edit=sakura]Delphi-Tags eingefügt. Mfg, sakura[/edit]

CalganX 14. Aug 2003 14:50

Re: Incompatible types: 'String' and 'TStrings'
 
Lines ist ja auch vom Typ TStrings.

Memos haben aber noch eine weitere Eigenschaft: Text.

Chris

[edit]Schnellster! :mrgreen:[/edit]

Christian Seehase 14. Aug 2003 14:51

Re: Incompatible types: 'String' and 'TStrings'
 
Moin Quakergod,

dann mach mal:

Delphi-Quellcode:
label4.Caption := memo1.lines.text;

Alexander 14. Aug 2003 14:51

Re: Incompatible types: 'String' and 'TStrings'
 
Ist auch logisch, weil halt TString <> String ist...
Nun gut versuch mal Label1.Caption := Memo1.Text. So sollte es funktionieren

[edit]Wieso komme ich eigentlich immer zu spät? :? :mrgreen:[e/dit]

Marco Haffner 14. Aug 2003 14:52

Re: Incompatible types: 'String' and 'TStrings'
 
label4.Caption ist vom Typ String, wärend memo1.lines vom Typ TStrings ist, die kannst Du natürlich nicht direkt zuweisen.
Dafür gibt es die Eigenschaft Text von TMemo.
Aber warum möchtest Du das ganze in einem TLabel darstellen?
Außerdem weist Du den Inhalt von Memo1 erst Label4 zu und lädst dann neuen Inhalt in Memo1.

Außerdem gibt es die Tags [ delphi] und [ /delphi], damit kannst Du deinen Source besser hervorheben.

[edit]Zu langsam.[/edit]

sakura 14. Aug 2003 15:06

Re: Incompatible types: 'String' and 'TStrings'
 
Mal so als Abschluss: Seit wann ist die Caption von Typ String :?:

Bei mir steht da immer der Typ TCaption, welcher wiederum als string definiert ist. :mrgreen:

Immer diese Krümmelkac..r :roll:

...:cat:...

quakergod 14. Aug 2003 15:13

Re: Incompatible types: 'String' and 'TStrings'
 
hui, vielen dank für eure hilfe! (funktioniert super)
eine sache wüsste ich aber noch gerne...

if label2.caption ungleich memo1.lines.text then ...

wie schreib ich das in 'delphi' ? :bouncing4:

sakura 14. Aug 2003 15:15

Re: Incompatible types: 'String' and 'TStrings'
 
NUTZE BITTE DIE DELPHI-TAGS :!: :!: :!:

Delphi-Quellcode:
if label2.caption <> memo1.lines.text then
...:cat:...

quakergod 14. Aug 2003 15:28

Re: Incompatible types: 'String' and 'TStrings'
 
sorry, dachte mein gekritzel wäre kein delphi :roll:
danke aber, hat super gefunzt und ich hab jetzt ne tolle möglichkeit die programmversion zu checken! :D


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:44 Uhr.

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