Autor Beitrag
csigg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 25.05.05 13:51 
Wie bekomm ich aus nem Str ein Ascii zeichen.
Der String besteht nur aus einem einzelnen Zeichen.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 25.05.05 14:07 
Behandle den String wie ein Array. Allerdings wird beim String bei 1 (eins) angefangen zu zählen.
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 25.05.05 14:09 
das war mir auch klar, drum hab ich ja aus dem String in einzelnes Zeichen gemacht, zu erklärung hier mal mein Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
 Edit2.Clear;
     laenge := length(edit1.Text);
     for i := 1 to laenge do
     begin
          s := edit1.Text[i];
          zahl := integer(PCHAR(s));
          edit2.Text := edit2.Text + intToStr(zahl) + ' ';
     end;
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 25.05.05 14:09 
Aber so bekomm ich ne ziemlich grosse Zahl heraus, z.b bei e = 12655748.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 25.05.05 14:11 
Ich glaube, dass geht nicht.
Du musst wohl erst Edit1.Text einer String variablen zuweisen oder die Copy-Funktion benutzen:
ausblenden Delphi-Quelltext
1:
s := copy(Edit1.Text, 1, 1);					
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 25.05.05 14:12 
user profile iconcsigg hat folgendes geschrieben:
Aber so bekomm ich ne ziemlich grosse Zahl heraus, z.b bei e = 12655748.

Weil du dir die Adresse des Zeichens ausgeben lässt. Wofär brauchst du denn PChar an der Stelle?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 25.05.05 14:13 
Ich frage mal zwischendurch, was denn deiner Meinung aus dem 'e' für eine Zahl herauskommen soll. Soll überhaupt eine Zahl herauskommen, oder ein Zeichen?

_________________
We are, we were and will not be.
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 25.05.05 14:13 
ich habs jetzt auf so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
 Edit2.Clear;
     laenge := length(edit1.Text);
     eingabe := edit1.Text;
     for i := 1 to laenge do
     begin
          s := eingabe[i];
          zahl := integer(PCHAR(s));
          edit2.Text := edit2.Text + intToStr(zahl) + ' ';
     end;

geändert, komt aber das selbe ergebnis raus.
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Mi 25.05.05 14:14 
ausblenden Delphi-Quelltext
1:
zahl := integer(PCHAR(s));					


da bekommste nen pointer.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var s: String;
zahl; byte;
begin
  s := 'blubbububu';
  zahl := byte(s[3]);
end;

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 25.05.05 14:15 
PChar steht immer noch drin.
Wenn du den ASCII-Wert des Zeichens haben möchtest genügt ord(s). S muss dann vom Type Char sein.
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 25.05.05 14:17 
geht auch nicht, da kommt immer Fehler bei Bereichsprüfung.
Mir egal, ich mach jetzt feierabend und am Freitag wieder weiter.

Wünsch euch nen schönen Feiertag.
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 25.05.05 14:18 
@jasocul
danke, das klingt ganz gut, ich probiers mal aus am Freitag.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Mi 25.05.05 14:21 
user profile iconcsigg hat folgendes geschrieben:
Wie bekomm ich aus nem Str ein Ascii zeichen.
Der String besteht nur aus einem einzelnen Zeichen.
Meinst du etwas wie:
ausblenden Delphi-Quelltext
1:
myInteger := Ord(myString[1]);					
crakos
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 195


D2k5 Pers
BeitragVerfasst: Do 26.05.05 19:24 
ja genau
ausblenden Delphi-Quelltext
1:
2:
for i := 1 to length(Edit1.Text) do  
  edit2.Text := edit2.Text + intToStr(ord(Edit1.Text[i])) + ' ';

_________________
Das Ende der Menschheit ist der Anfang der Unendlichkeit.
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Fr 08.07.05 14:19 
OK, danke
DaRkFiRe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 526

WinXP Home & Professional
C, C++, Delphi
BeitragVerfasst: Sa 09.07.05 04:28 
BTW macht ORD auch nix weiter als einen Typecast von CHAR nach BYTE.

_________________
Lang ist der Weg durch Lehren - kurz und wirksam durch Beispiele! Seneca
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 09.07.05 08:17 
Performancemäßg wäre es evtl. besser, wenn du nicht immer im Edit arbeiten würdest, sondern lieber in Variablen, die du zum Schluss ausgibst.
DaRkFiRe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 526

WinXP Home & Professional
C, C++, Delphi
BeitragVerfasst: Sa 09.07.05 08:23 
user profile iconHeiko hat folgendes geschrieben:
Performancemäßg wäre es evtl. besser, wenn du nicht immer im Edit arbeiten würdest, sondern lieber in Variablen, die du zum Schluss ausgibst.


Dem muss ich voll und ganz zustimmen, da bei jeder Änderung die Eventhandler abgearbeitet werden und refresht wird.

Lieber alles in einen (nicht sichtbaren) String schreiben und zum Schluss ans Control übergeben!

_________________
Lang ist der Weg durch Lehren - kurz und wirksam durch Beispiele! Seneca
N1m3
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30


Borland Delphi 2005 Personal
BeitragVerfasst: Di 19.07.05 17:23 
Hi, hoffe der Thread ist noch offen um eine Frage zu stellen.

user profile iconcrakos hat folgendes geschrieben:

ausblenden Delphi-Quelltext
1:
2:
for i := 1 to length(Edit1.Text) do  
  edit2.Text := edit2.Text + intToStr(ord(Edit1.Text[i])) + ' ';


Wie kann ich aus diesem Code die zahlen in Buchstaben umtauschen?

ich hab das schon so versucht:
ausblenden Delphi-Quelltext
1:
2:
for i := 1 to length(Edit1.Text) do  
  edit2.Text := edit2.Text + chr(StrToInt(Edit1.Text[i])) + ' ';


Aber die Zahl 123456 gibt dann nur:
     

aus :?:
crakos
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 195


D2k5 Pers
BeitragVerfasst: Di 19.07.05 23:32 
verstehe nicht was du machen wilst Oo

also du hast ne zahlenreihe, und was willst du damit machen???

_________________
Das Ende der Menschheit ist der Anfang der Unendlichkeit.