Autor Beitrag
GrU3nL!nG
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 29.05.05 16:40 
Also ich bin dabei mit der turtle zu zeichenen.
das ist aber nicht so dass problem.
es geht eher um eine FOR schleifen, die nicht so will wie ich es will^^...
hier der quell code:
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus, StdCtrls, ExtCtrls, UTurtle;

type
  TForm1 = class(TForm)
    Turtle1: TTurtle;
    Button1: TButton;
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Beende1: TMenuItem;
    Button2: TButton;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Beende1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  i: integer;
  ecken,winkel: real;

implementation

{$R *.DFM}

procedure TForm1.Beende1Click(Sender: TObject);
begin
form1.close;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 ecken:=strtofloat(edit1.text);
 winkel:=360/ecken;
 for i:=1 to ecken do
     begin
     turtle1.turn(winkel);
     turtle1.Draw(15);
     end;
end;

end.


so der gibt mir aus, dass eine for schleife eine einfache lokale variable sein.
warum kann ich das so nicht machen?
die variable ecken is doch LOKAL?!
EDIT: ich möchte mit der turtle ein n-.eck zeichenen, wo man die ecken in edit1.text bestimmt.


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am So 29.05.2005 um 22:39
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 29.05.05 16:44 
Wieso ist ecken ein Real und kein Integer? :gruebel:
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 29.05.05 16:47 
user profile iconGrU3nL!nG hat folgendes geschrieben:
so der gibt mir aus, dass eine for schleife eine einfache lokale variable sein.
warum kann ich das so nicht machen?
die variable ecken is doch LOKAL?!

Weil die Variable I bei dir global und nicht lokal ist.

_________________
Ciao, Sprint.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: So 29.05.05 16:48 
Ecken muss INTEGER sein, oder hast du schon mal versucht in ganzen Zahlen bis 2,5 zu zählen?

_________________
Programmers never die, they just GOSUB without RETURN
GrU3nL!nG
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 29.05.05 16:54 
Also wenn ich ecken INTEGER mache siht die fehlermeldung so aus:
user defined image

Ich hatte das auch schon ausprobiert...
GrU3nL!nG
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 29.05.05 16:56 
hab es glöst!!!
es heißt nicht strtofloat sonder strtoint !!!

danke!
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 29.05.05 16:57 
Float=Gleitkommawert. Real=gleitkommawert => StrToFloat benutzen
Integer=Ganze Zahl. => IntToStr benutzen. (NICHT FLOATTOSTR xD)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.