Return values

The data type of a C function can be established by explicit data type declaration in the Declare statement, by a data type suffix on the function name in the Declare statement, or by an applicable Deftype statement. One of these must be in effect. If not, the data type of the return value defaults to Variant, which is illegal for a C function.

LotusScript® data type

Legal as C function return type?

C data type

Boolean

Yes

bool

Byte

Yes

byte

Integer

Yes

int

Long

Yes

long

Single

Yes

float

Double

Yes

double

Currency

No

String

Yes, except for fixed-length string

char * or char[]

Variant

No

Product object

Yes (as a 4-byte object handle of type Long)

See LSX toolkit for details

User-defined object

Yes

See LSX toolkit for details

Type instance

No

Any

No

Array

No

List

No

The following example uses five Windows 3.1 API functions. The user identifies a window in which to work. The script finds the window, resets the window text, and yields control as long as the user keeps the focus in the window. When the user moves focus out of the window, the script restores the original window text and displays a message. If the user asks for a window that does not exist or is not running, the script also displays an appropriate message.

All declarations are at the module level.

' Gets the handle of the active window.
Declare Function GetActiveWindow Lib "User32" () As Long
' Gets the handle of the next window.
Declare Function GetNextWindow Lib "User32" _
                    (ByVal hwnd As Long, _
                    ByVal uFlag As Long)
                    As Long
' Windows constant for uFlag parameter: return the handle
' of the next(not the previous) window in the window
' manager's list.
Const GW_HWNDNEXT =2
' Makes a window (identified by its handle) the active window.
Declare Sub SetActiveWindow Lib "User32" (ByVal hwnd As Long)
' Gets the text in the window title bar.
Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" _
                    (ByVal hwnd As Long, _
                    ByVal lpString As String,_
                    ByVal chMax As Long) As Long
' Sets the text in the window title bar.
Declare Sub SetWindowText Lib "User32" Alias "SetWindowTextA" _
                    (ByVal hwnd As Long, _
                    ByVal lpString$)