Well, I've done a function, but it's not working.
The purpose of this function is to download a file and when finished, return true
.
This is the function:
function TForm1.BaixarArquivo(Sender: TObject; Url:String; Name:Integer):Boolean;
var
fileTD : TFileStream;
begin
fileTD := TFileStream.Create(IntToStr(Name) + ExtractFileExt(Url), fmCreate);
try
Sender.Get(Url, FileTD);
finally
FreeAndNil(fileTD);
end;
end;
I declare this in the public:
function BaixarArquivo(Sender: TObject; Url:string; Name:Integer): Boolean;
And I called it:
BaixarArquivo(IdHTTP1, 'http://pokestage.ddns.net/patch/5.rar', 5);
But returns this error:
[Error] LauncherUnit.pas (66): Undeclared identifier: 'Get'
Second function:
function TForm1.RetornaPorcentagem(ValorMaximo, ValorAtual: Real):string;
var
resultado: Real;
begin
resultado := ((ValorAtual * 100) / ValorMaximo); Result := FormatFloat('0%', resultado);
end;
The error is from Floating division by Zero.