Autor Beitrag
g1o2k4
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Fr 21.12.07 18:14 
hi

in meinem RAD Studio 2007 spukt es....
ich habe ein Memo fenster und nen button...der button macht was mit dem text von memo fesnter.
aber immer wenn man den button klick ändert die TForm ihre Caption auf den text der im memo fenster steht !?

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:
procedure TForm1.Button1Click(Sender: TObject);
var i,j: integer;
    temp, count, M: integer;
    k: double;
begin
     Zeichen := TStringList.create;

     Text := '';
     Text := MText.Text;
     M := length(MText.Text);

     for i := 0 to High(Werte) do
         Werte[i] := 0;

     SetLength(Werte,M);
     count := 0;

     for j:=1 to length(Text) do
     begin
          if Zeichen.IndexOf(Text[j]) > -1 then
          begin
               temp := Zeichen.IndexOf(Text[j]);
               Werte[temp] := Werte[temp]+1;
          end
          else
          begin
               Zeichen.Add(Text[j]);
               Werte[count] := Werte[count]+1;
               inc(count);
          end;

     end;

     for i:=0 to Zeichen.Count-1 do
     begin
          MText.Lines.Add(Zeichen[i] + '' + floattostr(Werte[i]));
     end;

     for i:=0 to Zeichen.Count-1 do
     begin
          Werte[i] := RundeAufStelle(Werte[i]/M, 3);
     end;

     for i:=0 to Zeichen.Count-1 do
     begin
          MText.Lines.Add(Zeichen[i] + '' + floattostr(Werte[i]));
     end;
     Zeichen.Free;
end;


das ist der quelltext des buttons... steht da was von caption ändern ? ich checks nicht...
Zorro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win 2000, Win XP Pro
Delphi 7 Architect
BeitragVerfasst: Fr 21.12.07 18:23 
user profile icong1o2k4 hat folgendes geschrieben:
hi

in meinem RAD Studio 2007 spukt es....
ich habe ein Memo fenster und nen button...der button macht was mit dem text von memo fesnter.
aber immer wenn man den button klick ändert die TForm ihre Caption auf den text der im memo fenster steht !?

das ist der quelltext des buttons... steht da was von caption ändern ? ich checks nicht...


Also ohne nähere Infos zu den sonst in der Proc autauchenden Vars (Werte...) kann man nicht sehr viel sagen.... Immerhin rührst du durchaus im Speicher rum (setlength)

Greetz
Zorro
g1o2k4 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Fr 21.12.07 18:25 
also oben drüber steht nur noch

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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Math;

type
  TForm1 = class(TForm)
    MText: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public

    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Werte: array of double;
  Zeichen: TStringlist;
  M: integer;
  Text,TextS: String;


implementation


{$R *.dfm}


und unten drunter

ausblenden Delphi-Quelltext
1:
end.					


das wars !
Zorro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win 2000, Win XP Pro
Delphi 7 Architect
BeitragVerfasst: Fr 21.12.07 18:36 
user profile icong1o2k4 hat folgendes geschrieben:
das wars !


Von daher wär ja mal interessant, welchen Wert zB "high(werte)" hat, da offenes Array. Und angesichts des Aufrufs von "RundeAufStelle" bin ich auch skeptisch, dass "sonst nichts" da drin steht.

Greetz
Zorro

Moderiert von user profile iconNarses: Vollständiges Zitat gekürzt
g1o2k4 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Fr 21.12.07 18:40 
genau danke. die funktion hatte ich übersehn:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
function RundeAufStelle(zahl: double; stellen: integer): double;
var multi: double;
begin
  multi:=IntPower(10, stellen);
  zahl:=round(zahl*multi);
  result:=zahl/multi;
end;



im einzelschritt modus sieht man folgendes:
( 1. post: Zeile 8 und 9)

ausblenden Delphi-Quelltext
1:
2:
     Text := ''// TForm1.Caption wird ''
     Text := MText.Text; // TForm1.Caption wird MText.Text
TProgger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 148

XP
D6, D2007 prof
BeitragVerfasst: Fr 21.12.07 18:59 
ich würde die Var "Text" mal anders nennen, denn "Text" ist eine Art reserviertes Wort bzw. eine Eigenschaft, die viele Komponenten haben und es daher zu Irritationen kommen kann.

_________________
Wir haben für jede Lösung das richtige Problem ;)
DrRzf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Sa 22.12.07 05:28 
Man kann die Caption der Form auch über

ausblenden Delphi-Quelltext
1:
Form1.Text := MeinText;					


ändern. Hier greifst du dann sozusagen auf die Caption der Form zu.

_________________
rein statistisch gesehen darf man keiner statistik trauen die man nicht selbst gefälscht hat.
g1o2k4 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Sa 22.12.07 08:46 
ok dann scheint es die lösung des problems zu sein, dass Text reserviert ist. danke !