Autor Beitrag
Robii
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Mo 01.06.09 22:56 
Hallo.
ausblenden Delphi-Quelltext
1:
            if i = 65 then if shift = true then t:='A' else t:='a';;					

klappt ja noch. Aber ich möchte gerne folgendes:
ausblenden Delphi-Quelltext
1:
            if i = 65 then if shift = true then t:='A' shift := false else t:='a';;					


Allerdings dürfen keine Ends vorhanden seien, da das ganze in
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
            if i = 53 then t:='5';
            if i = 54 then t:='6';
            if i = 55 then t:='7';
            if i = 56 then t:='8';
            if i = 57 then t:='9';
            if i = 65 then if shift = true then t:='A' else t:='a';;
            if i = 66 then t:='B';
            if i = 67 then t:='C';
            if i = 68 then t:='D';

geschieht und mit einem End die Variablen die zugewiesen sind nicht mehr funktionieren.

Wie kann ich dies realisieren?
Ps.: Mit einer eigenen Procedure habe ich es versucht scheitere aber daran, das ich nicht weiß wie ich die Werte i & t später wieder übergeben soll.
Grüße.
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mo 01.06.09 23:01 
Wie wäre es mit case?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 01.06.09 23:03 
Außerdem sollte man NIE explizit gegen True oder False Abgleichen; ein Boolean ist ein Boolean ist ein Boolean!

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Mo 01.06.09 23:04 
Sorry, kenne mich noch nicht so gut mit Delphi aus,
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
Außerdem sollte man NIE explizit gegen True oder False Abgleichen; ein Boolean ist ein Boolean ist ein Boolean!
was willst du mir hiermit sagen?

Grüße.

Moderiert von user profile iconNarses: Zitat repariert
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 23:08 
Suchst du vielleicht den Befehl Chr? Der wandelt den Asciicode in den Buchstaben um... (65 --> 'A', 66 --> 'B', ...)
Und Ord macht das Gegenteil.

user profile iconRobii hat folgendes geschrieben Zum zitierten Posting springen:
was willst du mir hiermit sagen?
Der Vergleich mit Booleanwerten (z.B. if shift = true then) ist nicht nur unschön und unlogisch, sondern falsch.
Hier habe ich mal ein kleines Beispiel gebastelt, wann es schief geht:
www.delphi-forum.de/....php?p=548760#548760
Mehr dazu steht hier:
www.delphi-treff.de/...olean-werten/page/4/
Und warum das auch vollkommen unlogisch ist:
www.delphi-forum.de/....php?p=560637#560637
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Mo 01.06.09 23:15 
Kann mir jemand einen Beispiel-Code zu dem 'case' geben ?
Weiß nicht genau, wie ich das da eibringen soll.Grüße.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 23:19 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
case i of
  ...
  53: t:='5';
  54: t:='6';
  55: t:='7';
  56: t:='8';
  57: t:='9';
  65if shift then t:='A' else t:='a';
  66: t:='B';
  67: t:='C';
  68: t:='D';
  ...
end;
oder einfach (wie gesagt):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if shift then
  t := Chr(i)
else
  t := Chr(i + 32);
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Mo 01.06.09 23:21 
Moderiert von user profile iconNarses: Komplett-Zitat des letzten Beitrags entfernt.

Das war mir schon klar, aber es ging ja darum, das der untere Code ergänz auf folgendes werden muss :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
  53: t:='5';
  54: t:='6';
  55: t:='7';
  56: t:='8';
  57: t:='9';
  65if shift then t:='A' shift := false else t:='a';
  66: t:='B';
  67: t:='C';
  68: t:='D';

das nachdem dann ein großes A geschrieben worden ist, die Shift - Taste indirekt auch wieder false ist.
Grüße.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 23:23 
Da fehlt dann begin und end, aber was hast du gegen Chr, da sparst du dir doch die ganze manuelle Behandlung...
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Mo 01.06.09 23:27 
Chr ?
Wie benutze ich das?

Weiß gar nicht was das ist und bin aus dem Beitrag eben auch nicht wirklich schlau geworden wie ich mir das vorstelllen soll.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 23:29 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
  t := Chr(i);					
Das gibt den Buchstaben zu dem Asciicode zurück, wie gesagt...
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Mo 01.06.09 23:31 
Ok, und wie unterscheide ich dann zwischen groß & klein ? Verstehe das Prinzip noch nicht so ganz.
Grüße.
Georg08
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155
Erhaltene Danke: 6

Win XP
Delphi 7.0 Personal
BeitragVerfasst: Mo 01.06.09 23:31 
Delphi-Syntax:
ausblenden Delphi-Quelltext
1:
function Chr(X: Byte): Char;					

Beschreibung

Chr gibt das Zeichen zurück, das dem im Byte-Wert X angegebenen Ordinalwert (ASCII-Wert) entspricht.


Zuletzt bearbeitet von Georg08 am Mo 01.06.09 23:34, insgesamt 1-mal bearbeitet
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 23:32 
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 02.06.09 00:04 
ich weiß nicht wie ich das einbringen soll. Kann mir da jemand evtl. einen Beispiel-Code schreiben?
Steh auf der Leitung.

Grüße.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 02.06.09 00:06 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
  t := Chr(i);					
Das ist das Beispiel... :roll:
Das macht von dem Shift abgesehen das selbe wie dein ganzes if bzw. case...
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 02.06.09 00:28 
Wie kann ich die Funktion denn jetzt noch so erweiter, das sie groß & klein Schreibung beachtet ?

Grüße.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 02.06.09 00:30 
Die Funktion beachtet die von sich aus, streng nach Tabelle (siehe oben). Wenn du den Asciicode anders interpretieren willst, dann musst du z.B. 32 addieren um aus einem Groß- einen Kleinbuchstaben zu machen und umgekehrt.
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Di 02.06.09 00:54 
Oder mir lowercase bzw. uppercase arbeiten...
mein delphi hat da sone schöne funktion wenn man f1 drückt...
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 02.06.09 01:25 
Mein Delphi hat keine schöne Funktion wenn man F1 drückt, weil man mit Vista die Hilfe-Datei nicht mehr lesen kann.

Mein Programm basiert aber auf der Eingabe, das heißt, das wenn jemand etwas eingibt die Funktion aktiv wird, wie kann ich da feststellen, ob ein großes A oder ein kleines a eingegebn worden ist?

Grüße.