Autor Beitrag
pHaRyNx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 94

win 95, win 2000, win xp, VISTA, Ubuntu 8.04
Delphi 7 PE
BeitragVerfasst: Mi 28.12.05 13:40 
hallo!
ich brauche einen befehl, der mir buchstaben/zeichen in ASCII-Code (->ZAHLEN) umwandelt.
So soll z.B. ein Wort in Zahlen zerlegt werden, um damit Berechnungen anzustellen (Bsp.: Serialroutine).
mfg pHaRyNx
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 28.12.05 13:47 
Delphi-Hilfe -> Ord
pHaRyNx Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 94

win 95, win 2000, win xp, VISTA, Ubuntu 8.04
Delphi 7 PE
BeitragVerfasst: Fr 30.12.05 13:55 
soweit klappt der befehl auch, nur gibt es ein problem, wenn ich der Ord()-Anweisung eine Variable übergebe (s. Bsp.). Die Variable enthält einen einstelligen String, da die Funktion sonst sowieso meckert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
...
var teil1:String;
  teil2:Integer;

begin

{ist jetzt vereinfacht, sonst würde jetzt eine for-schleife das edit-feld zeichenweise einlesen und umwandeln}

teil1:='t';

teil2:=Ord(teil1);

end;


aber beim Compilen stoppt der Compiler immer, und ich weiss nicht warum.
was kann man da machen?
mfg pHaRyNx

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


Zuletzt bearbeitet von pHaRyNx am Fr 30.12.05 14:33, insgesamt 1-mal bearbeitet
stifflersmom
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194

XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
BeitragVerfasst: Fr 30.12.05 14:10 
Na, es muß ja auch
ausblenden Delphi-Quelltext
1:
ord(teil1)					

heißen.

Moin
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 30.12.05 14:21 
Hallo,

da wird der Compiler aber auch meckern,
da teil1 von user profile iconpHaRyNx als String deklariert wurde :wink:

Die Funktion Ord erwartet einen Ausdruck des Typs Ordinal oder Char.
Der folgende Code gibt den ASCII-Code für das erste Zeichen im Edit aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var i : Integer;
    c : Char;
begin
  c := Edit1.Text[1];
  i := Ord(c);
  showmessage(IntToStr(i));

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
pHaRyNx Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 94

win 95, win 2000, win xp, VISTA, Ubuntu 8.04
Delphi 7 PE
BeitragVerfasst: Di 03.01.06 16:27 
ah, danke, ich wusste das mit dem CHAR nicht so ganz. danke. klappt jetzt.