MichiWw
(Michael Werwein)
February 19, 2025, 7:50am
1
Hi, I got a warning while using await, but the code compiles and run fine.
But I got two warnings if I use "String" behind Await(String
See sample and screenshot, please.
What can I do?
Thanks!
.
.
[async]
procedure WebButton1Click(Sender: TObject);
.
.
procedure TMain.WebButton1Click(Sender: TObject);
var
sha: TWebSHAHash;
s:String;
begin
sha:=TWebSHAHash.Create(ehSHA256);
s:=Await(String, sha.Hash('Some text'));
M_State.Lines.Add(s);
end;
await() doesn't expect the type as 2nd parameter, so please use:
s := Await(sha.Hash('Some text'));
MichiWw
(Michael Werwein)
February 19, 2025, 10:48am
3
Thanks, this fix the first Warning.
The 2nd Warning "Kann nicht als Konstantenobjekt übergeben werden" is still there. If I define a local variable than the error is "Kann nicht als Var Parameter übergeben werden". But if I look in the Source I see
TWebSHAHash.Hash(AText: string), so why I got a warning?
Thanks and best regards
MichiWw
(Michael Werwein)
February 19, 2025, 10:58am
4
Sorry, this does not work also. s does not match which String. How I can get the result as a string. Thanks!
Tunde
(Tünde Keller)
February 19, 2025, 1:41pm
6
Hi,
Can you try TAwait.ExecP
instead? The following works here:
procedure TForm1.WebButton1Click(Sender: TObject);
var
sha: TWebSHAHash;
s: string;
begin
sha := TWebSHAHash.Create(ehSHA256);
s := TAwait.ExecP<string>(sha.Hash('Some text'));
WebMemo1.Lines.Add(s);
end;