0
I have a. txt file encoded and need to copy the decoded content to another . txt.
In the first file, I have the following:
Gcbqrm5mnp4
Gcbqrm5mnp8
Gcbqrm5mnpc
When the new file is created, it is returning the correct number of lines, but only with the first item of the decoded list:
Bitmap_1
Bitmap_1
Bitmap_1
And the comeback should be:
Bitmap_1
Bitmap_2
Bitmap_3
The code I’m using:
var
arq, arqDec : TextFile;
linha, nome : string;
s : Integer;
begin //Decodifica o texto do arquivo
AssignFile(arq, FrmCadastro.CBUsuario.Text +'-images.txt');
Reset(arq);
while not Eof(arq) do
begin
Readln(arq, linha);
s := Pos(Encode64('Bitmap_'), linha);
nome := Copy(linha, 1, s-1);
Delete(linha, 1, s);
ShowMessage(Decode64(linha)); //<--Até aqui dá o retorno correto (ShowMessage usado só pra testar)
end;
begin
AssignFile(arqDec, FrmCadastro.CBUsuario.Text +'-Decod-images.txt');
if not (FileExists(FrmCadastro.CBUsuario.Text +'-Decod-images.txt')) then
Rewrite(arqDec)
else
Begin
Append(arqDec);
Writeln(arqDec, Decode64(linha));
end;
end;
CloseFile(arq);
CloseFile(arqDec);
end;
What am I doing wrong? Or what is missing to record the correct data in the new file . txt?
Nelson, you are writing in the file outside the loop that reads the source file. Try to improve the endentation that is easy to notice, ok?
– Ricardo Alves Carvalho