[fpc-devel] procedure Types
Michael Van Canneyt
michael at freepascal.org
Mon Mar 13 11:17:22 CET 2006
On Mon, 13 Mar 2006, Amir Aavani wrote:
> Any idea to call:
> BeginThread (@MyObject.F1, Pointer (S))
You can't do this. MyObject.F1 is a method, not a procedure.
You should do something like:
Function MyThreadProc(P : Pointer) : Integer;
(don't remember the exact form of the thread function.)
Or better yet, use TThread.
> Michael Van Canneyt wrote:
>> On Sat, 4 Mar 2006, Amir Aavani wrote:
>>> I have problem with procedure Types.
>>> Look at the following code:
>>> TProcedure= procedure (S: String);
>>> TTest= class
>>> MyF: TProcedure;
>>> procedure F1 (S: String);
>>> procedure F2 (S: String);
>>> TTest.constructor ;
>>> MyF:= @F1;
>>> it says it can't cast "Procedure (S: String); Object" to TProcedure. The
>>> problem is clear but I don't know
>>> (can't find) any solution to define TProcedure as a procedure of a class
>>> accepts one argument.
>> Try the following (note the 'of object' in the declaration):
>> TMyStringProc = procedure (S : String) of object;
>> and then
>> MyF : TMyStringProc;
>> This is documented.
>> fpc-devel maillist - fpc-devel at lists.freepascal.org
> fpc-devel maillist - fpc-devel at lists.freepascal.org
More information about the fpc-devel