Einzelnen Beitrag anzeigen

Benutzerbild von Jens Hartmann
Jens Hartmann

Registriert seit: 11. Jan 2009
Ort: Wilnsdorf
1.439 Beiträge
 
Delphi XE2 Professional
 
#9

Re: eine Textdatei (.txt) in Dephi auswerten

  Alt 9. Jan 2010, 14:27
Hallo,

ich habe das Beispiel mal fertig gestellt.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  SMSList : TStringList;
  i : integer;
  iZeichen : integer;
  SMSBool : Boolean;
  temp : String;
begin
  SMSList := TStringList.Create;
  SMSList.LoadFromFile( 'C:\Users\jens.hartmann\Documents\Superdepp.txt' );

  SMSList.Text := UpperCase( SMSList.Text ); // Alles in GROSS
  SMSList.Text := StringReplace( SMSList.Text, ' ', '', [ rfReplaceAll ] ); // Leerzeichen raus
  SMSList.Text := StringReplace( SMSList.Text, '==', '=', [ rfReplaceAll ] ); // doppelte = Zeichen raus
  MEMO1.Text := SMSList.Text;
  MEMO1.Refresh;
  Sleep(2000); //nur zur Anzeigeverzögerung im MEMO

  i := 0;
    while i < SMSList.Count do
      begin
        if Pos( 'SUPERDEPP=', SMSList[ i ] ) = 1 then
          inc( i )
        else
          SMSList.Delete( i );
      end;
  MEMO1.Text := SMSList.Text;
  MEMO1.Refresh;
  Sleep(2000); //nur zur Anzeigeverzögerung im MEMO


   i := 0;
    while i < SMSList.Count do
      begin
        temp := SMSList[i];
        for iZeichen := 1 to 9 do
          begin
            SMSBool := false;
            if pos (IntToStr(iZeichen), temp) = 11 then
              SMSBool := true;
            if SMSBool then
              Break;
          end;
        if not SMSBool then
          SMSList.Delete(i);
        inc(i)
      end;
  MEMO1.Text := SMSList.Text;
end;
Kann man eigenlich irgendwie folgendes auch mit "POS" machen...

Delphi-Quellcode:
  if pos(['0'..'9'],SMSList[i]) = 11 then
  //oder
  if pos(IntToStr([0..9]),SMSList[i]) = 11 then
Gruß Jens
Jens Hartmann
Das Leben selber ist zu kurz, also nutze jeden Tag wie er kommt.
  Mit Zitat antworten Zitat