4 4 LANSA Open and Excel

LANSA Open Guide

4.4 LANSA Open and Excel

When creating applications with Excel macros, you do not have to explicitly define the LANSA Open DLL functions to Excel. The functions are simply called directly as external functions within a macro.

The DLL functions can be called using the Excel CALL command where the command might be used as follows:

SET.NAME("nSessionId",CALL("LCOEW32","LceGetSessionId","I"))

or

CALL("LCOEW32","LceEndSession","AIA",nSessionId, FALSE)

The format of the CALL command is:

CALL("A","B","C",D,E,...)

where

   A is the name of the DLL file, LCOEW32

   B is the name of the LANSA Open function to be executed

   C is the description of the parameters. The format is XYZ,

    where

          X is the type of return value

          Y is the type of the first parameter

          Z is the type of the second parameter, etc.

 

   D, E ... are the parameters passed to the function

For more information about using the CALL command, refer to the Excel guides. In particular, review the data types used for parameter passing. An appendix in the Excel guides will list the data types.

In the example:

CALL("LCOEW32","LceEndSession","AIA",nSessionId, FALSE)

the parameters "AIA" indicate that the function returns a Boolean and is passed an integer and a Boolean.

Commonly used values include:

  • A is a Boolean passed by value
  • C is a zero-terminated ANSI string passed by reference
  • I is a signed integer passed by value.

Where the function returns a boolean operator, the LANSA Open functions are commonly used in this manner:

 

IF(NOT(CALL("LCOEW32","LceOpenSession","AI",nSessionId)),RETURN(FALSE))

Be sure to refer to the Excel macro samples provided.