Autor Beitrag
walter_b
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 135

Windows Vista/XP
Delphi 6
BeitragVerfasst: Di 04.09.07 18:03 
In der Hilfe steht:

ausblenden Delphi-Quelltext
1:
function VarComplexCreate(const AReal, AImaginary: Double): Variant; overload;					



jetzt will ich auf diese Funktion zugreifen:

ausblenden Delphi-Quelltext
1:
z:=VarComplexCreate(1,15);					



z ist als "variant" definiert. Er meldet mir immer: Undeclared identifier...

Was ist hier falsch? Vielen Dank!

Moderiert von user profile iconChristian S.: I- durch Delphi-Tags ersetzt
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 04.09.07 18:50 
Hast Du alle benötigten Units laut Hilfe in deiner Unit eingebunden?

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
walter_b Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 135

Windows Vista/XP
Delphi 6
BeitragVerfasst: Di 04.09.07 18:57 
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:
program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  z, z1: extended;
  r, max, i, im, l: double;
  komplex: variant;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  writeln ('Komplexe Zahlen by Deny Ammann');




  write('Realteil von Z: ');
  readln (r);

  write('Imaginaerteil von Z: ');
  readln (im);

  komplex:=VarComplexCreate(1,15);
  writeln (komplex);

  i:=1;
  z:=0;
  max:=5000;

  repeat

  z1:= z*z + r;
  z:=z1;
  writeln(FloatToStrF(z, ffGeneral, 100, 100));
  l:=i+1;
  i:=l;
  
  until i>=max;
  readln;
end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 04.09.07 19:08 
Da fehlen genau zwei Units. Welche das sind, verrät Dir die Delphi-Hilfe.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
walter_b Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 135

Windows Vista/XP
Delphi 6
BeitragVerfasst: Di 04.09.07 19:41 
Okay, ich habe in der Hilfe gesehen, dass das Unit VarCmplx fehlt und habe das noch hinzugefügt! Aber jetzt ignoriert er bei mir einfach das readln, also sehe ich absolut nichts mehr, schliesst einfach! Habe ich noch was vergessen?
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Di 04.09.07 20:00 
Also warum dein Programm sich schließt seh' ich grad net, aber 'n paar grundsätzliche Vorschläge hätte ich da:

ausblenden Delphi-Quelltext
1:
var i: double; // <-- ist ja später dein Counter und deshalb Integer					

Statt
ausblenden Delphi-Quelltext
1:
2:
  l:=i+1; 
  i:=l;

kannst du schreiben: i := i + 1; oder inc(i)

Edit:
Zitat:

Realteil von Z: 1
Imaginaerteil von Z: 2
1 + 15i
1
2
5
26
677
458330
210066388901
4,4127887745906176E22
1,94727047691529645E45
3,79186231026592608E90
1,43782197800152463E181
2,06733204042421677E362
4,27386176536455545E724
1,82658943894450344E1449
3,33642897846359586E2898
Exception EOverflow in module Project1.exe at 0001F4A2.
Floating point overflow.

Deine Rechnung wächst ins unermässliche...

Gruß

Calculon
--
walter_b Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 135

Windows Vista/XP
Delphi 6
BeitragVerfasst: Di 04.09.07 20:04 
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:
program Project2;

{$APPTYPE CONSOLE}

uses
  VarCmplx,SysUtils;

var
  z, z1: extended;
  r, max, im, l: double;
  komplex: variant;
  i: integer;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  writeln ('Komplexe Zahlen by Deny Ammann');




  write('Realteil von Z: ');
  readln (r);

  write('Imaginaerteil von Z: ');
  readln (im);

  komplex:=VarComplexCreate(r,im);
  i:=1;
  z:=0;
  max:=5000;

  repeat

  z1:= z*z + r;
  z:=z1;
  writeln(FloatToStrF(z, ffGeneral, 100, 100));
  i:=i+1;

  until i>=max;
  readln;
end.




So, das ist jetzt der aktuelle, angepasste Quelltext. Ihr könnt es ja ev. mal selbst ausprobieren, aber bei mir schliesst sich das Teil immer selber...


Edit:

Ich weiss, es ist auch nicht für so grosse Zahlen gedacht, sondern eher so um 0.02 und ähnliches. Und genau dies ist die Frage, ob es ins unendliche läuft oder nicht! Aber wie hast du das zum laufen gebracht?
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Di 04.09.07 20:08 
Öffne cmd.exe. Ziehe per Drag&Drop deine Project.exe-Datei in die Konsole und drücke Enter.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Di 04.09.07 20:47 
"Abgesichert" gestartet sehen wir, dass die Zahlen wohl zu groß für deine Variablen werden. :)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
 
...
 try
   repeat
       z1:= z*z + r;
       z:=z1;
       writeln(FloatToStrF(z, ffGeneral, 100, 100));
      i:=i+1;
   until (i >= max);
 except
    writeln('error');
 end;
...