I’m not really in favor of giving the fish to the guys, so I’m going try to teach you to fish:
We have the following text file, called test.txt(that must be in the same executable folder, to facilitate our test):
123456789012345678901234567890
COL1 COL2 COL3
DADO1 DADO2 DADO3
TESTE1 TESTE2 TESTE3
Note that the line 123456789012345678901234567890
should not go to the text file, consider it a ruler, assuming the TXT you are working on is typed.
Considering your txt is small, we’ll use a StringList
to capture his data as follows:
procedure TForm1.Button1Click(Sender: TObject);
var
arquivo : TStringList;
i : integer;
begin
arquivo := TStringList.Create;
arquivo.LoadFromFile('teste.txt');
end;
Now your file is all in StringList
File and is ready to be compared with any value as follows:
for i := 0 to arquivo.Count - 1 do
begin
Showmessage('Primeiro campo: ' + copy(arquivo[i],1,10)); //Primeiro Campo
Showmessage('Segundo campo: ' + copy(arquivo[i],11,10)); //Segundo Campo
Showmessage('Terceiro campo: ' + copy(arquivo[i],21,10)); //Terceiro Campo
end;
From there stays with you the insertion in the StringGrid
, the validation and use of the DLL from Bematech, Daruma or whatever the manufacturer. The created loop will go through the entire StringList
. Remembering that it starts at 0 and goes up arquivo.count - 1
by the index of TStringList
start at 0 and not at 1.
Welcome to Stack Overflow in Portuguese.To prevent your response from being flagged and consequently closed, I suggest you add what you searched for, if you found anything, what you found, or what you know about Delphi that can help you with this task. Here the community usually reward the effort to ask a good question with great answers, so good luck!
– Filipe.Fonseca