Data and reference types

The table below contains a cheat list of data type correspondence between C and LotusScript. One characteristic mismatching feature is that C may contain both signed and unsigned types. All LotusScript datatypes with the exception of BYTE and String are signed. If WORD value in C is from 0 to 65535, Integer value in LotusScript is from -32768 to 32767.

It does not mean much when passing variables or when they get processed by C code – in hexadecimal representation it makes in both cases 0 to 0xFFFF; however when calculating in LotusScript special provisions should be made to treat the overflow correctly.

C

LotusScript

Comments

BYTE

Byte

does not exist in LotusScript prior to Notes Domino 6

WORD

Integer

Signed in LotusScript

SWORD

Integer

Signed word/integer

DWORD

Long

-“”-

LONG

Long

Signed in both – LotusScript and C

HANDLE, NOTEHANDLE, DBHANDLE

Integer

Macintosh, UNIXEes (except Linux, OS/390 and Solaris x86)

Long

OS/2, Win32, Linux, Solaris x86, OS/400, OS/390

MEMHANDLE

Long

Unsigned in C

Char *, Char * far

String

Most of the parameters are passed by reference, i.e. passed a pointer to the variable; with little exceptions by value passed are WORD or DWORD flags and handles.

The following table shows when to pass variables by Value and when by Reference

Declared in C

Declared in LotusScript

Comments

WORD someWord

ByVal someWord as Integer

The arguments contain one word (or 2 bytes) value of variable

* WORD pSomeWord

SomeWord as Integer

Or

ByRef someWord as Integer

Pointer to word value; arguments contain a pointer to value – usually Long or DWORD

* * DWORD hSomeWord

somePointer as Long

or

ByRef somePointer as Long

Pointer to pointer; this one is a bit tricky; pointer is long in all OSes except OS400 where it is 16 bytes – so this is not applicable to OS/400

Char *, Char * far SomeStr

ByVal someStr as String

For some esoteric reason to pass a pointer to string we need to declare it by value; according to Designer help declaration byRef is possible, but C program must expect the specific format – C API does expect a normal pointer.

Char * far *far SomeStr

pSomeString as Long

Pointer to pointer to string

* SOMESTRTYPE someStr

SomeStr as SomeStrType

Structure by reference

SOMESTRTYPE someStr

ByVal SomeStrElement1 as Integer, ByVal SomeStrElement2 as Integer,

This one is nasty, structure is passed by value; only way in LotusScript is to declare several parameters byVal, besides there may be alignment issues between different platforms