Autor Beitrag
stigge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 28.02.07 21:41 
Hallo! Ich habe mal wieder ein Problem:
Ich möchte Quellzeichen in normalen Text umwandeln lassen.
Geht aber nicht.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var pass1: string;
    pass2: string;
...
pass1 := ord(pass2);

So einfacher Text aber geht nicht.
Weiß jemand warum?
Und mit Quellzeichen meine ich z.B.: #34, #76. #98, ...
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 28.02.07 21:44 
ausblenden Delphi-Quelltext
1:
pass2 := chr(val(pass1));					

_________________
Markus Kinzler.
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 28.02.07 21:51 
Ähmmmm... und was heißt val?
Und außerdem:

[Fehler] Unit1.pas(51): E2035 Nicht genügend wirkliche Parameter
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mi 28.02.07 21:57 
Was du da als Quellzeichen bezeichnest sind AFAIR Unicodes.
Die kannst du mit WideLowerCase bzw. WideUpperCase umwandeln.
Check dazu mal die Delphi Hilfe (F1 drücken)

MfG
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 28.02.07 21:59 
Ich glaube eher ich meine ASCII-Zeichen^^
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 28.02.07 22:05 
[quote="user profile iconstigge"]Ähmmmm... und was heißt val?[/quote}
Val wandelt eine Zahl in einem String in die zahl und ignoriert dabei "falsche" Zeichen.
Also aus '50 €' wird dann 50.
Zitat:
Und außerdem:

[Fehler] Unit1.pas(51): E2035 Nicht genügend wirkliche Parameter
Wo tritt der Fehler genau auf?

_________________
Markus Kinzler.
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 28.02.07 22:09 
Vielleicht sollte ich es genauer formulieren:
Ich will einen string z.B: test@123 in Quellzeichen umwandeln und später wieder zurück.
Ich bin ziemlich sicher das es mit chr geht aber wie?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 28.02.07 22:16 
Die Quellzeichen kannst du mit pass1 := '#'+Ord(s[x]); erzeugen

_________________
Markus Kinzler.
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mi 28.02.07 22:19 
ich muss halt ungefähr 200 zeichen umwandeln^^
gibt's nicht eine schnellere methode?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 28.02.07 22:26 
Ne Schleife über das x:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
    Codes: array of String[4];
    x: integer;
    ...
    SetLength( Codes, Length(s);
    for x := 0 to Length(s) -1 do
    begin
       Codes[x] := := '#'+Ord(s[x+1]);
    end;

_________________
Markus Kinzler.
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Do 01.03.07 15:17 
OK, danke!