LOTUSSCRIPT LANGUAGE


Declare statement (external C calls)
Example

Declares a LotusScript function or sub that calls an external C function, allowing calls to a function that is defined in a shared library of C routines.

Note the Declare statement (external C calls) is not supported under OS/2.

Syntax

Declare [ Public | Private ] { Function | Sub } LSname Lib libName [ Alias aliasName ]
( [
argList ] ) [ As returnType ]

Elements

Public | Private


Function | Sub
LSname
libName
aliasName
argList
returnType
Usage

The Public keyword cannot be used in a product object script or %Include file in a product object script, except to declare class members. You must put such Public declarations in (Globals).

You can only declare external functions at the module level. If a function is not typed with a return type or a data type suffix character, LotusScript generates an error.

The "_" is reserved for Notes specific DLLs. This is a change put in as of Notes 4.5.1. If you attempt to load a DLL in Notes 4.51 or greater using LotusScript and the name of the DLL is preceded by an underscore you will receive the error "Error in loading DLL".

Passing arguments

By default, LotusScript passes arguments to external functions by reference. Arguments can be passed by value using the ByVal keyword, but only if LotusScript can convert the value passed to the data type of the corresponding C function argument.

Arrays, type variables, and user-defined objects must be passed by reference.

You can't pass lists as arguments to C functions.

You can't use a fixed-length String as an argument.

Product objects can be passed by reference (passing a reference to the instance handle) or by value (passing the instance handle itself). They can be passed by value only by using the keyword ByVal. Parentheses can't be used on the actual argument.

An argument can be typed as Any to avoid data type restrictions. Arguments of type Any are always passed by reference, regardless of the type of data they contain. You can pass a Variant containing an array or list to a C function argument declared as Any.

Using LMBCS or Unicode strings

Use the optional keywords LMBCS and Unicode with a String argument or returnType to specify the character set.

Unicode designates a Unicode string of two-byte characters (words) using the platform-native byte order.

LMBCS designates a LMBCS optimization group 1 string (multibyte characters).

If neither LMBCS nor Unicode is specified, the string variable uses the platform-native character set.

Calling exported library functions in 32-bit versions of Windows

If you're using a 32-bit version of Windows, the names of exported library functions are case sensitive; however, LotusScript automatically converts them to uppercase in the Declare statement. To successfully call an exported library function, use the Alias clause to specify the function name with correct capitalization (LotusScript leaves the alias alone).

Example
See Also