1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
procedure Tform1.Traitement();
var
Start:integer;
Stop:integer;
DonneeValide:string;
BonneTrame:string;
begin
//== on cherche
//== US,GS,+0039,98 g
//Debut par 'US' ou 'ST'
repeat
Start:= max(pos('US',RichEdit1.text) , pos('ST',RichEdit1.text));
//Fin par 'g' ou 'ozt' ou 'ct
Stop:=max(Pos('g',RichEdit1.text),Pos('ozt',RichEdit1.text));
Stop:=max(Pos('ct',RichEdit1.text),Stop);
if (Start=0) or (Stop=0) then
begin
//== On ne trouve aucun debut ou aucune fin alors on sort
//== immediatement de la boucle
break;
end;
//== Validation ==
if Start>Stop then
begin
//== On a une fin de trame mais il manque le debut ===
//== le buffer contient donc quelque chose comme:
//== +0039,98 g US,GS,+0039,98 g
//== on elimine donc le debut ==
RichEdit1.text:=Copy(RichEdit1.text,Start,Length(RichEdit1.text))
end
else
begin
//== ici une donnée est surment valide ==
BonneTrame:=Copy( RichEdit1.text,Start,Stop-Start);
//== Enleve le texte traité
RichEdit1.text:=Copy(RichEdit1.text,Stop+1,Length(RichEdit1.text))
//== TODO: faudrait faire quelque chose avec? ==
end;
until false; //== Boucle infini, la sortie via le break! ==
end; |
Partager