Autor Beitrag
Paulus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

win xp

BeitragVerfasst: Mi 22.09.04 13:48 
Kurze Noob-Frage:

Ich hab folgenden code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var zahl:integer;
..
..
..
zahl:=10;
label.caption :=zahl;

Jetzt krieg ich jedoch beim kompilieren immer folgende fehlermeldung:
Zitat:
Inkompatible Typen: 'String und Integer'

Wenn ich zahl in anführungszeichen schreibe, erscheint beim ausführen des programmes natürlich "zahl" anstatt "10". Ich will jedoch die variable ausgeben! In php ging das ja mit "echo $variable;". Wie geht das denn hier in Delphi?

Moderiert von user profile iconTino: Delphi- & Quote-Tags hinzugefügt.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 22.09.04 13:49 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var zahl:integer; 
.. 
.. 
.. 
zahl:=10; 
label.caption :=IntToStr(zahl);


Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
Paulus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

win xp

BeitragVerfasst: Mi 22.09.04 13:55 
Danke! Der wandelt also den Integer jetzt in einen string um? (interpretier ich jetzt einfach mal so rein ^^ )
Paulus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

win xp

BeitragVerfasst: Mi 22.09.04 13:59 
ähm ich hab nochmal ne frage ^^

ich will, dass zu einer variablen +10 addiert wird, so lange folgende Bedingung erfüllt ist:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
while timer.enabled==true
do
begin
zahl=zahl+10;
end;

Jetzt krieg ich die fehlermeldung:
Zitat:
Ausdruck erwartet, aber "=" gefunden

Bitte helft mir nochmal. Da stimmt was am syntax nicht ^^

Moderiert von user profile iconTino: Delphi- & Quote-Tags hinzugefügt.
atarigold
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 84

WIN XP, Linux 2.4
D7, Delphi 2006 Prof
BeitragVerfasst: Mi 22.09.04 14:02 
zahl:=zahl+10;
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Mi 22.09.04 14:02 
In Delphi reicht ein "=", das ist hier schließlich nicht C. Bei Boolschen Ausdrücken kann das "=" aber auch ganz weggelassen werden:
ausblenden Delphi-Quelltext
1:
while xykompo.enabled do ...					


Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Mi 22.09.04 14:03 
atarigold hat folgendes geschrieben:
zahl:=zahl+10;

Das wäre dann das nächste gewesen. ;-)

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Jörg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 71

Win 2000, Win XP
Delphi 1, 3, 5, 7
BeitragVerfasst: Mi 22.09.04 14:03 
ausblenden Quelltext
1:
2:
3:
4:
5:
while timer.enabled==true 
do 
begin 
zahl=zahl+10; 
end;

Das ist C-Code. In Delphi geht das so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
while timer.enabled=true 
do 
begin 
zahl:=zahl+10; 
end;

Kleiner Verbesserungsvorschlag zu Zeile 1: Statt "while timer.enabled = true" schreibst Du lieber "while timer.enabled", enabled ist schon boolean, das muß man nicht noch mit einer booleschen Variable vergleichen.

Jörg.

Moderiert von user profile iconTino: Code- & Delphi-Tags hinzugefügt.
Jörg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 71

Win 2000, Win XP
Delphi 1, 3, 5, 7
BeitragVerfasst: Mi 22.09.04 14:04 
Oh, da war jemand schneller...

Jörg.
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Mi 22.09.04 14:07 
Das muss am Namen liegen ... ;-)

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Paulus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

win xp

BeitragVerfasst: Do 23.09.04 17:40 
Danke für die Hilfe.

Muss mich halt noch etwas von PHP zu Delphi umgewöhnen ^^.
Hab ja erst vor ne Woche mit delphi angefangen (Informatikkurs in der Schule). 8)