Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread small bug, interesting AI project
Tue, Feb 23 2021 6:18 PMPermanent Link

erickengelke

Avatar

Bug in prototypes for external functions passing a procedure.

I was porting an interesting Artificial Intelligence project.  It tracks a face on camera.  Fun!
https://erickengelke.com/faces/faces.html  (it has to be https for permissions for your camera)

When porting from EWB2 to EWB3 and came across a strange compiler bug: if you declare an external function that is passed a local function as a parameter, EWB balks at the definition.

The solution that works is to declare pointer to the function and then pass that.  But it didn’t used to be necessary in EWB2.

The following simple code will not compile in EWB3 but does in EWB2!

Type
 TDrawLandMarks =  procedure (results :  variant);  // local function

 external TOnPlay =  function (  videoE1 : variant; options : variant ; drawlandmarks :TDrawLandMarks ): array of variant;

var
 external onPlay2 :TOnPlay;

procedure DrawLandmarks2( results :  variant );
begin
  Form1.localdrawlandmarks( results );
end;

function somefunction();
var
  playoptions : variant;
begin
 playoptions := 0;
 // next line fails, wanting an integer or variant, or whatever, but not accepting the function
  face3 := onPlay2(  videoE2, playoptions, drawLandmarks2 );
end;
EWB Programming Books and Component Library
http://www.erickengelke.com
Image