Domino Code Fragment

Code Name*
How to Determine if Optional Arguments Have Been Provided for a Method. Product Release: LSX Toolkit 2.0
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.144.250.169
Description*
How to Determine if Optional Arguments Have Been Provided for a Method.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

Problem:
How can you determine whether optional arguments have been provided for a method?


Solution:
When calling a method from LotusScript, you can omit optional arguments. For example, you
have a method with three arguments, and the last two are optional: (DMethod(integer, long
optional, string optional))


In LotusScript you could call this method in many ways. For example:

DMethod (5)
DMethod (5, 100)
DMethod (5, 100, "Test")
DMethod (5, , "Test")


To determine if an argument has been omitted, you can use the bitwise "and" operator with
the LSVT_OMITTED constant.

Example of Code within a Method in an LSX:

void DClass:: DMethod (PLSADTMSGMETHOD args)
{
PLSVALUE pval;
int Arg1;
long Arg2;
char * Arg3;
int Len;


pval = &args->pArg[0];
Arg1 = pval->vShort;


pval = &args->pArg[1];
if ( (pval->Type & LSVT_OMITTED) != LSVT_OMITTED)
Arg2 = pval->vLong;
else
Arg2 = 0


pval = &args->pArg[2];
if ((pval-?Type & LSVT_OMITTED) != LSVT_OMITTED)
{
Len = strlen((LSPLTSTR)pval->vString);
if (Len)
{
Arg3 = new char[Len+1];
memmove(Arg3, pval->vString, len+1);
}
else
Arg3 = 0;
}
else
Arg3 = 0;
}