Autor Beitrag
der auenländer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25

WIN XP
Delphi 6 PE
BeitragVerfasst: Sa 17.03.07 18:18 
Hallo zusammen. ich muss für infa wieder en programm schreiben, welches strings austauscht (nach dem motto 'drii chinisin mit dim kintribiss') hab den programm code soweit fertig, aber an einer stelle meckert der compiler immer noch beim umsetzen. leider hab ich nich den hauch einer ahnung, was er mit seiner fehlermeldug meinen könnte. wäre lieb, wenn einer von euch mir kurz sagen könnt, wo der fehler liegt!
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:
unit UChinesen;

interface

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

type
  TForm1 = class(TForm)
    EVokal: TEdit;
    Label1: TLabel;
    MUmgesetzterText: TMemo;
    MOriginalText: TMemo;
    BtUmsetzen: TButton;
    procedure FormCreate(Sender: TObject);
    procedure vokalErsetzen (var text : String; vokal : Char);
    procedure BtUmsetzenClick(Sender: TObject);
    function istVokal (buchstabe : char):boolean;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  text : string;
  Buchstabe : char;
  cnt : integer;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  MoriginalText.Lines.Clear;
  MOriginaltext.Lines.Add('Drei Chinesen mit dem Kontrabass, saßen auf der Straße und erzählten sich was.');
end;

procedure TForm1.vokalErsetzen (var text : String; vokal : Char);
var cnt : integer;
begin
  for cnt:=1 to length(text) do
    if istVokal(text[cnt])
    then text[cnt]:=Vokal;
end;

function TForm1.istVokal (buchstabe : char):boolean;
begin
  Buchstabe:=Upcase(Buchstabe);
  istVokal:=(Buchstabe='A') or (Buchstabe='E') or
            (Buchstabe='I') or (Buchstabe='O') or
            (Buchstabe='U') or (Buchstabe='Ä') or
            (Buchstabe='Ö') or (Buchstabe='Ü');
end;

Procedure TForm1.BtUmsetzenClick(Sender: TObject);
var i : integer;
  text, vokal : String;
begin
  MUmgesetzterText.Lines.Clear;
  text :=MOriginalText.text;
  vokal:=EVokal.Text[1];
  vokalErsetzen (text[cnt]);         //hier sagt er:Types of actual and formal var parameters must be identical
  MUmgesetzterText.Lines.Add(text);
  end;
end.


danke!
lg,
Jannik
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 17.03.07 18:39 
Du musst text und nicht text[cnt] übergeben, da du die Variable dann in der Prozedur mit einer Schleife durchläufst. Und nenn die Variable bitte nicht text, denn dadurch kann es zu verwechslungen mit Memo.Text kommen!

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 17.03.07 19:13 
mir kommt die IstVokal Funtion ein bisschen komisch vor. Müsste das nicht so heißen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
function TForm1.istVokal (buchstabe : char):boolean;
begin
  Buchstabe:=Upcase(Buchstabe);
  result:=(Buchstabe='A') or (Buchstabe='E') or
            (Buchstabe='I') or (Buchstabe='O') or
            (Buchstabe='U') or (Buchstabe='Ä') or
            (Buchstabe='Ö') or (Buchstabe='Ü');
end;

_________________
In the beginning was the word.
And the word was content-type: text/plain.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 17.03.07 19:14 
Nein, du kannst auch den Funktionsname anstatt Result benutzen.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 17.03.07 19:17 
Oh mein Gott, du hast recht. :shock: Das wusste ich noch gar nicht! :oops:
Wie peinlich...

_________________
In the beginning was the word.
And the word was content-type: text/plain.
der auenländer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25

WIN XP
Delphi 6 PE
BeitragVerfasst: Sa 17.03.07 23:19 
hi, danke erstmal fürdie schnellen antworten!

wenn ich das cnt wech nehme sagt er mir dann aber "not enough actual parameters". :roll:

jannik
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: Sa 17.03.07 23:28 
Moin,

versuchs mal so:

ausblenden Delphi-Quelltext
1:
 vokalErsetzen(text, vokal);					


Gruß

Saubäär
Michael Stenzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 133


D3 Prof, D7 PE
BeitragVerfasst: Sa 17.03.07 23:40 
Hi, dieses Funktioniert.

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

 
interface  

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

 
type  
  TForm1 = class(TForm)  
    EVokal: TEdit;  
    Label1: TLabel;  
    MUmgesetzterText: TMemo;  
    MOriginalText: TMemo;  
    BtUmsetzen: TButton;  
    procedure FormCreate(Sender: TObject);  
    procedure vokalErsetzen (var text : String; vokal : Char);  
    procedure BtUmsetzenClick(Sender: TObject);  
    function istVokal (buchstabe : char):boolean;  
  private  
    { Private declarations }  
  public  
    { Public declarations }  
  end;  

 
var  
  Form1: TForm1;  
  text : string;  
  Buchstabe : char;  
  cnt : integer;  
implementation  

 
{$R *.dfm}  

 
procedure TForm1.FormCreate(Sender: TObject);  
begin  
  MoriginalText.Lines.Clear;  
  MOriginaltext.Lines.Add('Drei Chinesen mit dem Kontrabass, saßen auf der Straße und erzählten sich was.');  
end;  

 
procedure TForm1.vokalErsetzen (var text : String; vokal : Char);  
var cnt : integer;  
begin  
  for cnt:=1 to length(text) do  
    if istVokal(text[cnt])  
    then text[cnt]:=Vokal;  
end;  

 
function TForm1.istVokal (buchstabe : char):boolean;  
begin  
  Buchstabe:=Upcase(Buchstabe);  
  istVokal:=(Buchstabe='A') or (Buchstabe='E') or  
            (Buchstabe='I') or (Buchstabe='O') or  
            (Buchstabe='U') or (Buchstabe='Ä') or  
            (Buchstabe='Ö') or (Buchstabe='Ü');  
end;  

 
Procedure TForm1.BtUmsetzenClick(Sender: TObject);  
var i : integer;  
  text : String;
  VoKal : char;          // Hier den Datentyp ändern
begin
  MUmgesetzterText.Lines.Clear;
  text :=MOriginalText.text;
  vokal:=EVokal.Text[1];
  vokalErsetzen (text,VoKal);         //hier die Parameter richtig einsetzen
  MUmgesetzterText.Lines.Add(text);  
  end;  
end.


Gruß
Michael.