Consultor Eletrônico



Kbase P143683: How to use Trigonometric Functions in the 4GL/ABL?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   20/10/2009
Status: Verified

GOAL:

How to use Trigonometric Functions in the 4GL/ABL?

GOAL:

How to use the ACOS, ASIN, ATAN, COS, COSH, SIN, SINH, TAN functions in the 4GL/ABL?

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
All Supported Operating Systems

FIX:

OpenEdge does not include native support for trigonometric functions. The only option to use trignometric functions from Progress/OpenEdge is to call API functions.
Option 1: On MS-Windows platform you may use Dynamic Link Libraries (DLLs) to call routines from the 4GL.The following sample codes illustrates how to call the Win32 trigonometric functions COS (Cosine) which reside in the Microsoft Visual C++ runtime library, msvcrt40.dll./* The following function returns the cosine of an angle in radians */

DEFINE VARIABLE decResult AS DECIMAL NO-UNDO.

PROCEDURE cos EXTERNAL "MSVCRT40.DLL" CDECL:
DEFINE INPUT PARAMETER dblValue AS DOUBLE NO-UNDO.
DEFINE RETURN PARAMETER dblResult AS DOUBLE NO-UNDO.
END PROCEDURE.

RUN cos (INPUT 75.655, OUTPUT decResult).

MESSAGE "The Cosine of 75.655 is " decResult VIEW-AS ALERT-BOX.

Option 2: On Unix/Linux systems HLC enables users to call C shared libraries from the ABL.The following sample code shows how to call the UNIX libm trigonometric function called Cos which resides in the UNIX shared library /usr/lib/libm.1, or /usr/lib/libm.so. /* The following function returns the cosine of an angle in radians */

DEFINE VARIABLE decResult AS DECIMAL NO-UNDO.

PROCEDURE cos EXTERNAL "/usr/lib/libm.1" CDECL:
DEFINE INPUT PARAMETER dblValue AS DOUBLE NO-UNDO.
DEFINE RETURN PARAMETER dblResult AS DOUBLE NO-UNDO.
END PROCEDURE.

RUN cos (INPUT 0.655, OUTPUT decResult).

MESSAGE "The Cosine of 0.655 is " decResult VIEW-AS ALERT-BOX.