I would like to directly write the process in Application. QueueAsyncCall, is it lazarus / 21-General ---------------------------------------------------------------------- myisjwj · 2023-05-22 09:32 Write as follows: Application.QueueAsyncCall(procedure (Data:PtrInt); var i:Integer begin i:=1; end,0); Lazarus reported an error  Error: Illegal expression Write as follows: Application.QueueAsyncCall(@(procedure (Data:PtrInt); var i:Integer begin i:=1; end),0); Lazarus reported an error  Error: Illegal expression May I ask what is the correct writing method? ---------------------------------------------------------------------- alpine · 2023-05-22 10:03 https://wiki.freepascal.org/Asynchronous_Calls ---------------------------------------------------------------------- Warfley · 2023-05-22 10:59 You probably either have not the trunk version of fpc, of have not enabled the anonymous function switch. The current stable fpc does not support anonymous functions yet, and even on trunk you need to activate them first (using {$ModeSwitch ANONYMOUSFUNCTIONS} in your unit) ---------------------------------------------------------------------- myisjwj · 2023-05-23 09:11 I have upgraded to the FPC (3.3.1) of trunk version, Lazarus is 2.3.0, but the problem still exists. Is there a writing problem. thank you ---------------------------------------------------------------------- bytebites · 2023-05-23 10:24 Correct syntax is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Application.QueueAsyncCall(procedure (Data:PtrInt) var i:Integer; begin i:=1 end,0); ---------------------------------------------------------------------- myisjwj · 2023-05-23 12:33 According to the above method, an error is still reported. Application.QueueAsyncCall(procedure (Data:PtrInt) var i:Integer; begin i:=1 end,0);   Error: Illegal expression Error: Syntax error, ")" expected but "(" found ---------------------------------------------------------------------- cdbc · 2023-05-23 13:13 Hi Have you by any chance forgotten:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ModeSwitch ANONYMOUSFUNCTIONS} in your unit? Regards Benny ---------------------------------------------------------------------- myisjwj · 2023-05-23 13:24 I started adding {$ModeSwitch ANONYMOUSFUNCTIONS} before {$mode objfpc}{$H+}. Now add it to the back. Thank you all!! ---------------------------------------------------------------------- PascalDragon · 2023-05-23 20:20 Quote from: myisjwj on May 23, 2023, 03:24:55 pmI started adding {$ModeSwitch ANONYMOUSFUNCTIONS} before {$mode objfpc}{$H+}. Now add it to the back. Thank you all!! A $mode directive resets all $modeswitch directives (including those provided on the command line or in the configuration file), so always put $modeswitch directives after a $mode directive.