was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

44 Visitors Online


 
...Strings als Selktionskriterien für CASE-Konstrukte benutzen?
Autor: Loïs Bégué
Homepage: http://www.begue.de
[ Tip ausdrucken ]  

Tip Bewertung (5):  
     


{
  Funktioniert unabhängig von der Klein-/Großscheibung in dem Input-String:
  Versuchen Sie es z.B. mit "Mother" oder "mOTHER"...

  Damit kann man seine eigene Makrosprache entwickeln oder bestimmte
  Teile eines Strings aus einem SQL statement, aus einer wohlgeformten Datei
  wie im XML-Format...interpretieren.
}

{
  It works fine and it's not case sensitive:
  Try to give "Mother" or "mOTHER" in the Input-String...

  For exemple, you may use this to programm your own macro command system.
  You can also parse a well formed text file (XML...)
  Or to interpret a Database Field name as a selector, or whatelse you want.
}


uses
  
TypInfo;

type
  
TNumericChoiceParent = (ncp_Mother, ncp_Father, ncp_Child);

procedure TForm1.btChooseClick(Sender: TObject);
var
  
S: string;
begin
  
S := InputEdit.Text;
  case TNumericChoiceParent(GetEnumValue(TypeInfo(TNumericChoiceParent), 'ncp_' + S)) of
    
ncp_Mother: ShowMessage('Hello Mom :o)');
    ncp_Father: ShowMessage('Hi, Dad -]');
    ncp_Child: ShowMessage('Shut up and eat your soup !-(');
  else
    
ShowMessage('Who do you think that you are?');
  end;
end;





 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners