Board index » delphi » Calling external procs from objects

Calling external procs from objects

Hi all,

is it possible in pascal 7.0 to call directly external routines from an
object?

ie, like:

type
  testobj = object
                   procedure testme;
                 end;

{$L testfile.obj}
procedure testme; far; external;

I cannot make the above work. If the external file's routine is called TESTME then
an error is reported because routine TESTOBJ.TESTME is not found. But I cannot
call the public routine TESTOBJ.TESTME either because the TASM won't accept
it!

Please help!

Cheers,

    Per

 

Re:Calling external procs from objects


In article <4171mh$...@henry.interlink.no>, pe...@interlink.no (Per I. Mathisen) writes:
|
| is it possible in pascal 7.0 to call directly external routines from an
| object?

  Should be no problem at all.

| ie, like:
| type
|   testobj = object
|                    procedure testme;
|                  end;
|
| {$L testfile.obj}
| procedure testme; far; external;
|
| I cannot make the above work. If the external file's routine is called TESTME then
| an error is reported because routine TESTOBJ.TESTME is not found. But I cannot
| call the public routine TESTOBJ.TESTME either because the TASM won't accept
| it!

  I'm having some trouble understanding what you mean here. Did you write any
  more code than what's given above? (If not then that's the error.) You get a
  compiler error? Where?
  --Lars M.
_______________________________________________________________________________

  -- Lars M. Garshol, Institute of Informatics, Oslo University

     "Life is a {*word*225}ly transmitted disease." -- A. Brink
     http://www.ifi.uio.no/~larsga

Re:Calling external procs from objects


lar...@ifi.uio.no (Lars Marius Garshol) writes:

Quote
>  I'm having some trouble understanding what you mean here. Did you write
>  any more code than what's given above? (If not then that's the error.)
>  You get a compiler error? Where?
>  --Lars M.

Of course.

First example:

--- test.pas

   type
   testobj = object
              function callme:byte;
             end;

   {$L here.obj}
   Function testobj.callme:byte; external;

   Begin
   End.

--- excerpt from here.asm

   ...
   PUBLIC callme
   ...

---

This gives compiler "Error 46: Undefined external (testobj.callme)".
Now, the fault is obvious: the PUBLIC statement in HERE.ASM does not
match the reference in TEST.PAS file.

But trying to write:

--- here.asm

   ...
   PUBLIC testobj.callme
   ...

---

Gives TASM error "Undefined symbol: TESTOBJ".

Writing,

--- test.pas

   ...
   {$L here.obj}
   Function callme:byte; external;

---

Will naturally result in "Error 59: Undefined forward (testobj.callme)"!

Writing,

--- test.pas

   type
   testobj = object
              function callme:byte; external;
             end;
   ...

---

Also gives a compiler error ( 'END expected' ).

Please help anyone.

Cheers,

   Per I Mathisen
   Trondheim
   Norway

Re:Calling external procs from objects


Quote
In article <perma.60.00144...@pr.uninett.no>, pe...@pr.uninett.no (Per Mathisen) writes:
> lar...@ifi.uio.no (Lars Marius Garshol) writes:

> >  I'm having some trouble understanding what you mean here. Did you write
> >  any more code than what's given above? (If not then that's the error.)
> >  You get a compiler error? Where?
> >  --Lars M.

> Of course.

> First example:

> --- test.pas

>    type
>    testobj = object
>               function callme:byte;
>              end;

>    {$L here.obj}
>    Function testobj.callme:byte; external;

>    Begin
>    End.

> --- excerpt from here.asm

>    ...
>    PUBLIC callme
>    ...

  This program contains two errors:
    i) The function TestObj.CallMe is not defined, you must enter this:

     function TestObj.CallMe : byte;
     BEGIN
       { Define callme here }
     END;

   ii) The external function is called TestObj.CallMe, it should be called
       just CallMe. The prefix "TestObj." means that CallMe is a method
       (TP/C++ lingo for procedure in a class/object type) in the object type
       TestObj, which it isn't (the external one, I mean.) Also, it's not a
       sjakktrekk :) to call the external procedure the same as a local object
       method.

  Try making both these changes, and then see what happens.
  --Lars M.

Re:Calling external procs from objects


Quote
In article <perma.60.00144...@pr.uninett.no> pe...@pr.uninett.no (Per Mathisen) writes:
>   {$L here.obj}
>   Function testobj.callme:byte; external;
>   Begin
>   End.
>--- excerpt from here.asm
>   ...
>   PUBLIC callme

>This gives compiler "Error 46: Undefined external (testobj.callme)".
>Now, the fault is obvious: the PUBLIC statement in HERE.ASM does not
>match the reference in TEST.PAS file.

Somewhere in the manual it tells you how to declare methods  in assembler.  As
I recall (but I don't have the manual handy), you use "testobj@callme".  The
problem is that the dot is already used for a different purpose in TASM.

Duncan Murdoch

Other Threads