Previous: About DLL's To the Table of Content Next: Writing DLL's

- 2.2.11.2 -
TMT Pascal Language Description
Pascal Language Structure
Dynamic-Link Libraries (DLL's)

Using DLL's

Targets: OS/2, Win32


TMT Pascal provides three ways to import procedures and functions:

By new name:
When a procedure or function is imported with a name clause specified, it is imported by a different name than its identifier.

By index:
When a procedure or function is imported with an index clause specified, it is imported by an ordinal (i.e. a given index).

By name:
When a procedure or function is imported with no index or name clause specified, it is imported explicitly by it's identifier name.

Example:

This external declaration imports the function ExitProcess from the system DLL called KERNEL32 (the Windows 32 kernel):
procedure ExitProcess conv arg_stdcall (uExitCode: DWORD);
                   external kernel32dll name 'ExitProcess';
Example:
This example program imports ArcCos and ArcSin functions from the DLL called ARCs (see Writing DLLs):
program TestDLL;
uses
  Strings;

const
  ARCs = 'arcs.dll';

// import by name
{$ifdef __WIN32__}
  function ArcCos conv arg_stdcall (X: Extended): Extended;
                                external ARCs name 'ArcCos';
{$else}
  function ArcCos conv arg_os2 (X: Extended): Extended;
                                external ARCs name 'ArcCos';
{$endif}
 
 // import by index
{$ifdef __WIN32__}
  function ArcSin conv arg_stdcall (X: Extended): Extended;
                                     external ARCs index 1;
{ $else}
  function ArcSin conv arg_os2 (X: Extended): Extended;
                                     external ARCs index 1;
{$endif}
 
var Arg: Extended;
 
begin
  repeat
    Write('Argument ? ');
    Readln(Arg);
    if (Arg < -1) or (Arg > 1) then
      Writeln('Argument must be in range: [-1..1]');
   until (Arg >= -1) and (Arg <= 1);
   Writeln('ArcCos(', Fls(Arg), ') = ', Fls(ArcCos(Arg)));
   Writeln('ArcSin(', Fls(Arg), ') = ', Fls(ArcSin(Arg)));
end.



Previous: About DLL's To the Table of Content Next: Writing DLL's
About DLL's Table of Content Writing DLL's

- 2.2.11.2 -