Autor Beitrag
Bagster
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 04.10.10 16:16 
Kann mir jemand von euch sagen wo her der string ---zs--- bei einer prozedur kommt? Am besten wärs, wenn mir einer das ganze Programm erklärt. Danke


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:
implementation

{$R *.dfm}

Const
bits = 15;

TYPE

bitblabla = array[0..bits] of shortint;
bitblabla2 = array[0..bits] of shortint;
bitblabla3 = array[0..bits] of shortint;
bitblabla4 = array[0..bits] of shortint;

VAR

bt : bitblabla ;
bt2: bitblabla2;
bt3: bitblabla3;
bt4: bitblabla4;

Bfolge : String ;
Bfolge2 : String ;
Bfolge3 : String ;


{procedure X_OR(zs:string; Var Bfolge:string);
Var
i : integer;
Begin

For I := 0 to 15  do  }




procedure umformung3(zs:stringVar Bfolge:string);
Var
i : integer;
z : integer;

Begin
z := strtoint (zs);
Bfolge := '';

for i := 0 to 15 do
begin
bt3[i] := z mod 2;
z := z div 2;
end;

for I := 0 to 15 do
Bfolge := IntToStr(bt3[I]) + Bfolge ;



End;

procedure umformung2(zs:stringVar Bfolge:string);
Var
i : integer;
z : integer;

Begin
z := strtoint (zs);
Bfolge := '';

for i := 0 to 15 do
begin
bt2[i] := z mod 2;
z := z div 2;
end;

for I := 0 to 15 do
Bfolge := IntToStr(bt2[I]) + Bfolge ;



End;


procedure umformung(zs:stringVar Bfolge:string);
Var
i : integer;
z : integer;

Begin
z := strtoint (zs);
Bfolge := '';

for i := 0 to 15 do
begin
bt[i] := z mod 2;
z := z div 2;
end;

for I := 0 to 15 do
Bfolge := IntToStr(bt[I]) + Bfolge ;

End;

procedure TForm1.Button1Click(Sender: TObject);
begin
  umformung(Edit1.Text, Bfolge);
  Label1.Caption := Bfolge;
  umformung2(Edit2.Text, Bfolge2);
  Label2.Caption := Bfolge2;
  umformung3(Edit3.Text, Bfolge3);
  Label3.Caption := Bfolge3;


Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt


Zuletzt bearbeitet von Bagster am Mo 04.10.10 19:17, insgesamt 1-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 04.10.10 16:19 
Moin!

Bitte ändere den Titel des Topics, da er wenig über das eigentlich Thema verrät. Hier der entsprechende Absatz aus den Richtlinien:
1.2 Beiträge:
Bitte formuliere den Betreff Deiner Beiträge so, dass andere Mitglieder anhand dieser bereits das eigentliche Thema festmachen können. Beiträge wie etwa "Eine Anfängerfrage" oder "Weiß jemand, wie das geht?" lassen den Leser im Unklaren darüber, was das Thema der Diskussion ist.[...]
Einfach oben bei Deinem ersten Beitrag auf user defined image oder user defined image klicken und den Titel ändern. Danke Dir!

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Mo 04.10.10 16:24 
user profile iconBagster hat folgendes geschrieben Zum zitierten Posting springen:
Kann mir jemand von euch sagen wo her der string ---zs--- bei einer prozedur kommt? Am besten wärs, wenn mir einer das ganze Programm erklärt. Danke


ausblenden Delphi-Quelltext
1:
2:
3:
  umformung(Edit1.Text, Bfolge);
  umformung2(Edit2.Text, Bfolge2);
  umformung3(Edit3.Text, Bfolge3);



Schau mal genau hin, dann weisst du wo zs herkommt...

_________________
mfg. Joel
MaxWurzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 77
Erhaltene Danke: 10



BeitragVerfasst: Mo 04.10.10 16:25 
Der String zs soll vermutlich vorher in ein Editfeld eingegeben werden.


Zuletzt bearbeitet von MaxWurzel am Mo 04.10.10 16:27, insgesamt 1-mal bearbeitet
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 04.10.10 16:25 
Hi und :welcome: im Forum!

Grob gesagt wandelt das Programm eine Dezimalzahl in das Binärsystem um.


Ich empfehle Dir aber dazu erstmal die Basics anzueignen.
Siehe:
o Delphi-Wikibook
o user profile iconChristians Crashkurs

Damit alleine sollte bereits einiges klarer werden. :)


Beste Grüße,
Marc

Für diesen Beitrag haben gedankt: Bagster
Bagster Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 04.10.10 19:31 
Danke für die Antworten. Kann mir jemand vll eine Definion von Xor im Bezug zum Binärsystem nennem? Kann keine geeignete Definition im Internet finden.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 04.10.10 19:47 
XOR ist ein "exclusive OR", also ein ausschließendes Bitweises-ODER.
D.h. wenn Bit A und B gleich sind, ist das Ergebnis False ('0'). Sind die beiden Bits hingegen verschieden, so ist das Ergebnis True ('1').
Also, entweder das Eine oder das Andere.
iterion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21
Erhaltene Danke: 2

Win XP ,Suse 11.3
Delphi 7
BeitragVerfasst: Mi 06.10.10 19:48 
Hab mal etwas geschrieben fuer eine serial port verbindung, die ausgabe erfolgt ueber eine string.

ausblenden 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:
function DecToB(number:integer):string;
var c,r,res:integer;
cdr,add:integer;
tmp:string;
begin
result:='';
c:=number;
while c>0 do
  begin
  r:=c mod 2;
  res:=c div 2;
  c:=res;
  result:=result+inttostr(r);
  end;
//reverse
tmp:='';
for cdr:=length(result)downto 1 do
tmp:=tmp+copy(result,cdr,1);
result:=tmp;
add:=8-length(result);
tmp:='';
// fill leading zeroes
for cdr:=1 to add do
tmp:=tmp+'0';
tmp:=tmp+result;
result:=tmp;
end;


Und so ruft man das ganze auf:
ausblenden Delphi-Quelltext
1:
label1.caption:=Dectob(strtoint(edit1.Text));					


Also als eingabe Zb. 20 da ist die ausgabe dann 00010100