(***********************************************)
(*                                             *)
(* Dynamic-link (DLL) Usage Sample             *)
(* Copyright (c) 1998 by TMT Development Corp. *)
(* Author: Vadim Bodrov, TMT Development Corp. *)
(*                                             *)
(* Targets:                                    *)
(*   OS/2 console application                  *)
(*   WIN32 console application                 *)
(*                                             *)
(***********************************************)

{$ifndef __OS2__}
{$ifndef __WIN32__}
  This program can be compiled for following targets only:
  -  OS/2 console application
  -  WIN32 console application
{$endif}
{$endif}

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.