Autor Beitrag
cola
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 20:51 
Hallo Leute,

ich hab da mal ne Frage.
Integer und Extended sind inkompatible Typen. Wie kann ich die beiden kompatibel machen?

Danke schon mal im Vorraus

Cola
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 18.05.05 20:54 
Titel: Integer und Extended kompatibel machen
Was verstehst du genau unter "kompatibel machen" ?
Willst du eine Extended-Zahl gerundet in eine Integer wandeln, oder was hast du vor?
Willst du vielleicht einer Extended-Variablen eine Integer zuweisen?

Du kannst rein mathematisch gesehen nicht einfach beide Typen kompatibel machen, ohne zu sagen, was dabei gestattet sein darf. So wirft sich die Frage auf, ob du die Nachkommastellen einfach abschnibbeln willst.

Erklär doch mal.

Gruß, Feivel
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Mi 18.05.05 20:55 
Hallo!

Einem Extended-Wert kannst du einfach einen Integer-Wert zuordnen:

ausblenden Delphi-Quelltext
1:
Extended := Integer;					


Andersrum musst du einfach den Extended-Wert runden:

ausblenden Delphi-Quelltext
1:
Integer := Round(Extended);					


Alstar
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 21:04 
wo genau muss ich den Befehl eingeben. ich hab ihn über meinen Variablendefinitionen eigegeben und da kommt die Fehlermeldung immer noch ([Fehler] Zykloid.pas(103): Inkompatible Typen: 'Integer' und 'Extended')

Gruß Cola
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Mi 18.05.05 21:06 
Nein. Du musst ihn mit deinen Variablen einsetzen:

ausblenden Delphi-Quelltext
1:
IntegerVariable := Round(ExtendedVariable);					


Alstar
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 21:11 
Sorry steh grad bissl aufm Schlauch aber wie genau meinst du das.
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 18.05.05 21:16 
Titel: Extended-Variablen runden
Poste doch bitte mal deinen nicht funktionierenden Quellcode.
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 21:20 
also nicht wundern wenn manches etwas umständlich ist, aber ich hab mit Delphi grad erst angefangen.

ausblenden volle Höhe 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:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
unit Zykloid;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Spin, Buttons;

type
  TForm1 = class(TForm)
    Start: TButton;
    Stop: TButton;
    Reset: TButton;
    BitBtn1: TBitBtn;
    SpinEdit1: TSpinEdit;
    PaintBox1: TPaintBox;
    Label1: TLabel;
    Label2: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Timer1: TTimer;
    Label6: TLabel;
    TM_Show: TTimer;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label3: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label14: TLabel;
    Label15: TLabel;
   // procedure PaintBox1Paint(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);
    procedure StartClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure TM_ShowTimer(Sender: TObject);
    procedure StopClick(Sender: TObject);
    procedure ResetClick(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
var xm : integer ;
    Radius1 : integer ;
    ym : integer;
    sekunde : integer = 0 ;
    xp,yp:integer;
    Winkel:integer = 0;
    t:integer = 0;
Extended : Integer;
const rp=2;


procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
   Radius1 := StrToInt (SpinEdit1.Text) ;
   //xm := StrToInt (SpinEdit1.Text) ;
   label1.Caption := IntToStr(Radius1);
   Start.Enabled := true;  // aktiviert Startbutton nach Select in SpinEdit
   tm_show.Enabled := true ;
end;

procedure TForm1.StartClick(Sender: TObject);
begin
   timer1.Enabled := true ;
   TM_Show.Enabled := true ;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
   inc (sekunde);
   label6.Caption := IntToStr (sekunde);
   xm := xm + 1 ;
   //xm := xm + 2 ;  // Timer1 Interval 75
end;

procedure TForm1.TM_ShowTimer(Sender: TObject);
begin
   with PaintBox1.Canvas do
  begin
   Pen.Color:=clblack;
   Pen.Width:=1;
   Rectangle(0,0,PaintBox1.Width,PaintBox1.Height);
   ym := Paintbox1.Height - radius1 ;  //berechnet ym
   Ellipse(xm-radius1,ym-radius1,xm+radius1,ym+radius1);
   label2.Caption := IntToStr(xm)  ;
   label3.Caption := IntToStr(Radius1);
   label4.Caption := IntToStr(ym)   ;
   Ellipse(xp-rp,yp-rp,xp+rp,yp+rp);
   //label14.Caption := ExtToInt(xp);
   //label15.Caption := ExtToInt(yp);
   Extended := Integer  ;
   xp:=(Radius1*t)-(Radius1*sin(t)) ;
   yp:=Radius1-(Radius1*sin(t))  ;
   t:=(Pi/180)*Winkel;
   Winkel:=Winkel+2*pi/18; //Winkelerhöhung um 1/500 (Intervall von Timer 1)

  end;
end;

procedure TForm1.StopClick(Sender: TObject);
begin
   timer1.Enabled := false ;
   tm_show.Enabled := false ;
end;

procedure TForm1.ResetClick(Sender: TObject);
begin
   ym := Paintbox1.Height - radius1 ;  //berechnet ym
   Radius1 := StrToInt (SpinEdit1.Text) ;
   xm := radius1 + 1 ;
   timer1.Enabled := false ;
   tm_show.Enabled := false ;
  with PaintBox1.Canvas do
    begin
    Pen.Color:=clblack;
    Pen.Width:=1;
    Rectangle(0,0,PaintBox1.Width,PaintBox1.Height);
    ym := Paintbox1.Height - radius1 ;  //berechnet ym
    Ellipse(xm-radius1,ym-radius1,xm+radius1,ym+radius1);
    yp:=ym-Radius1;
    xp:=xm+1-1;
    Ellipse(xp-rp,yp-rp,xp+rp,yp+rp);


end ;
end;

end.


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 18.05.05 21:27 
Ähm, ja,
vielleicht hätte ich sagen sollen, dass du uns auch die Stelle markierst, an der es nicht funktioniert.
Das ist ja eine ganze Menge Quell-Code. Und das mal eben so im Kopf durchzuspielen (da wir ja deine Applikation nicht haben...) ist nicht so einfach. Vor allem deshalb nicht, weil aus deinen Variablennamen nicht hervorgeht, um welchen Typ von Variable es sich handelt. Sicher, ich könnte jedes Mal oben in der Deklaration nachsehen, aber dafür gibt es sprechende Namen.
Wäre es möglich, dass du die Prozedur namentlich bekannt gibst, und auch die Zeile, an der das Problem ist?
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 21:30 
oh sorry, das hab ich ganz vergessen. Also im Prinzip ab

procedure TForm1.TM_ShowTimer(Sender: TObject);

aber ganz speziell kommt die Fehlermeldung für die Zeilen 99-106

Gruß Cola
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 18.05.05 21:49 
Titel: Namen von Variablen !
Also, folgendes würde ich dir als Verbesserung in deinen Programmen vorschlagen, damit du die Übersicht behältst:

Gib den Variablen eine Typenbezeichnung mit in den Namen.
z.B. wie folgt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var niXm      : integer ;  
    niRadius1 : integer ;  
    niYm      : integer;  
    niSekunde : integer = 0 ;  
    niXp      : integer;
    niYp      : integer;  
    niWinkel  : integer = 0;  
    niT       : integer = 0;  
    Extended  : Integer;        // Was soll das sein ???

const niRP    = 2;


Anmerkung:

ausblenden Quelltext
1:
2:
3:
4:
ni = numerisch integer
ne = numerisch extended
lb = logisch boolean
as = array of string

und so weiter

Dir selbst hilft das ungemein beim Finden der Fehler. Aber jetzt erklär mir mal, was das mit dem Extended : integer zu bedeuten hat.

Oh Gott, das lässt sich ja sogar kompilieren !!!
Delphi ist schon ziemlich dämlich.
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 21:52 
Achso das hat eigentlich nichts zu bedeuten. Da hatte ich nur was probiert und vergessen das wieder weg zu machen.
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 21:59 
also es klappt nicht. Fehler bei Zeilen 111 bis 114: Inkompatible Typen: 'Integer' und 'Extended'
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 18.05.05 22:00 
Tust du mir bitte einen Gefallen, bevor ich dir einen Gefallen tu ?
könntest du dein Projekt in ein ZIP packen und es mir auf
info@schaberick.de senden?
Ich sehe es mir gerne an, aber ich brauche die genaue Fehlermeldung über meinen Debugger.
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 22:03 
kein Problem wird sofort erledigt. Übrigens danke für deine Hilfe.

Gruß Cola
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 18.05.05 22:05 
Titel: Fehlermeldung Integer und Extended
Mail mir mal dein Zip-File. Dann sehe ich es mir an.
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 18.05.05 22:07 
Titel: Integer und extended
Hast du den AIM ? Wenn ja, dann trag mich doch mal eben als feivel3333 ein. Dann dauert das nicht immer so lange mit der Kommunikation.
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 18.05.05 22:07 
Kurze Frage. Das klingt jetzt wahrschienlich ziemlich unterbelichtet aber was ist ne Zip-File? Email ist schon abgeschickt. und was ist AIM?

Gruß Cola
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Mi 18.05.05 22:30 
user profile iconcola hat folgendes geschrieben:
Das klingt jetzt wahrschienlich ziemlich unterbelichtet aber was ist ne Zip-File? [...] und was ist AIM?


Naja. Ganz so drastisch würde ich es mir nicht anmaßen das so auszudrücken :wink:

ZIP-File = ZIP-Datei = Datei von Win-ZIP.

Ein Datei-Archiv, um Dateien komprimiert zu speichern

AIM = AOL Instant Massenger

Instant-Messanging Programm um Sofortnachrichten auszutauschen. Wie das baugleiche ICQ oder der MSN-Messanger

Alstar
crakos
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 195


D2k5 Pers
BeitragVerfasst: Mi 18.05.05 22:33 
Zip ist das englische Wort für Reisverschluß
Und der Name eines sehr bekanten Komprimierungsprograms
die komprimierte Datei hat die Endung .zip
Ein Weiteres Program ist WinRar mit der Endung .rar

_________________
Das Ende der Menschheit ist der Anfang der Unendlichkeit.