Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2000-03

Calling boolean type function

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Weustink
to Jean Bénard: JB : well a ; is missing here (it wasn't a copy/paste !) in Delphi for Windows, the @ is…

+ From: Jean B�nard
+
+ At 02:09 30/03/00 +0100, you wrote:
+ >Hi, I got the following problem:
+ >
+ >function Test: Boolean
+
+ JB : well a ; is missing here (it wasn't a copy/paste !)

Nope this is a condensed form of a larger problem

+ > MyFunc := @Test;
+
+ in Delphi for Windows, the @ is refused as well
+ while it compiles without @

This is not the error !

+ >The compiler complains about:
+ >
+ > Error: Incompatible types: got "TMYFUNC" expected "BOOLEAN"
+ >
+ >Am I missing something ??
+
+ No : on the contrary, the @ should be dropped.

I'm not talking about delphi, I'm talking about FPC !

Marc

Reply by email

Florian Klaempfl
to Jean Bénard: JB : well a ; is missing here (it wasn't a copy/paste !) in Delphi for Windows, the @ is…
Show quoted text 31 lines
At 02:09 30/03/00 +0100, you wrote: >Hi, I got the following problem: > >function Test: Boolean JB : well a ; is missing here (it wasn't a copy/paste !) >begin >end; > >type > TMyFunc = function: Boolean; >var > b: Boolean; > MyFunc: TMyfunc; > >begin > MyFunc := @Test; in Delphi for Windows, the @ is refused as well while it compiles without @ > b := MyFunc; >end; > >The compiler complains about: > > Error: Incompatible types: got "TMYFUNC" expected "BOOLEAN" > >Am I missing something ??
Try
b:=MyFunc();

else FPC believes you want to copy the contents of MyFunc to b.

Show quoted text 11 lines
No : on the contrary, the @ should be dropped. Jean B�nard Informatique premier cycle B�t 336 Campus d'Orsay 91405 ORSAY Cedex _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

Marc Weustink

Hi, I got the following problem:

function Test: Boolean
begin
end;
type
   TMyFunc = function: Boolean;
var
   b: Boolean;
   MyFunc: TMyfunc;
begin
   MyFunc := @Test;
   b := MyFunc;
end;

The compiler complains about:

Error: Incompatible types: got "TMYFUNC" expected "BOOLEAN"

Am I missing something ??

Marc

Reply by email

Marc Weustink
to Jean Bénard: JB : well a ; is missing here (it wasn't a copy/paste !) in Delphi for Windows, the @ is…
Florian Klaempfl wrote 11 lines
> >The compiler complains about: > > > > Error: Incompatible types: got "TMYFUNC" expected "BOOLEAN" > > > >Am I missing something ?? Try b:=MyFunc(); else FPC believes you want to copy the contents of MyFunc to b.

Thanks that did the trick (I thought that I tried it but apperently not)

Marc

Show quoted text 16 lines
> > No : on the contrary, the @ should be dropped. > > Jean B�nard Informatique premier cycle > B�t 336 Campus d'Orsay > 91405 ORSAY Cedex > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.miraclec.com/list_archives/lazarus _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

Jean Bénard
to Marc Weustink: Hi, I got the following problem: function Test: Boolean begin end; type TMyFunc =…
you wrote
Hi, I got the following problem: function Test: Boolean

JB : well a ; is missing here (it wasn't a copy/paste !)

Show quoted text 11 lines
begin end; type TMyFunc = function: Boolean; var b: Boolean; MyFunc: TMyfunc; begin MyFunc := @Test;

in Delphi for Windows, the @ is refused as well
while it compiles without @

Show quoted text 8 lines
b := MyFunc; end; The compiler complains about: Error: Incompatible types: got "TMYFUNC" expected "BOOLEAN" Am I missing something ??

No : on the contrary, the @ should be dropped.

Jean B�nard Informatique premier cycle
B�t 336 Campus d'Orsay
91405 ORSAY Cedex

Reply by email