C API guru help needed!
Anyone who knows how to write code to see which LotusScript subs/functions are defined in a script library using the C API?
It's not illegal or anything!! :-)
Re: C API guru help needed!
Easiest way to get a list is to export the library to DXL and parse the "code" nodes; each node has an "event" attribute that specifies the name of the function / sub. Sadly, since any classes are all lumped together in Declarations, this only works for top-level routines... to get class methods you'd have to do syntactical parsing of the grandchild of the Declarations node.
Re: C API
The C API does not allow you to specifically address specific subs, functions and classes defined in a script library. Since each library is a document in the NSF that you can read, you must parse the entire document(s) yourself to get that list. Same issue for trying to expose LS class members.
Re: C API guru help needed!
You can get $ScriptLib field via C API application and then you have to parse it your own way.
I mean, procedures begins with "++LotusScript Development Environment". You can parse this field value (Source Code of Script library) using String Parse methods.
How can you get this field ?
Answer :
Create new Win32 console application via MS Visual C++ 6.0 and set Project Properties to write code for Lotus Notes
Include main/necessary include files.
(You can find Notes C API toolkit from IBM web site and also there are more samples to find solution)
in the main function. Initilize notes using
/* Domino and Notes initialization */
if (error = NotesInitExtended (argc, argv))
{
printf("\n Unable to initialize Notes.\n");
return (1);
}
Then get target database. You can use this function.
DBHANDLE LNPUBLIC GetDatabase (char *chrFullPathName)
{
DBHANDLE hCustomDB = NULLHANDLE;
STATUS nError = NOERROR;
// Get Database - STARTED
if (nError = NSFDbOpen (chrFullPathName, &hCustomDB))
{
PrintAPIError ("GetDatabase", nError);
return (NULLHANDLE);
}
// Get Database - FINISHED
return (hCustomDB);
}
Usage :
DBHANDLE hDB;
hDB = GetDatabase("CN=APPDEV01/O=BESTCODER!!Sample.nsf");
or
hDB = GetDatabase("C:\Lotus\Notes\Data\Sample.nsf");
then;
Get target script library (Note)
// ---------------------------------
NOTEID IDLSNote;
NOTEHANDLE hLSNote;
WORD wRetLen;
char szFieldValue[DESIGN_FIELD_MAX+1];
char chrElementNam[DESIGN_FIELD_MAX+1];
nError = NIFFindDesignNote (hDB, "LS Library Note Name", NOTE_CLASS_FILTER, &IDLSNote);
if (nError != NOERROR )
{
return FALSE;
}
nError = NoteOpen (hNoteVERSION, IDLSNote, &hLSNote);
if (nError != NOERROR )
{
return FALSE;
}
wRetLen = NSFItemGetText(hNote, "$ScriptLib", szFieldValue, (WORD) sizeof(szFieldValue));
sprintf(chrCodes, "%s", szFieldValue);
// Now you have LS Library procedures in chrCodes
NSFNoteClose (hLSNote);
NSFDbClose (hDB);
// ---------------------------------
I hope, this post will help you to find solution. And sorry, it covered big area on this page.
Regards,
Ferhat Ikbal BULUT
www.bestcoder.net
I mean, procedures begins with "++LotusScript Development Environment". You can parse this field value (Source Code of Script library) using String Parse methods.
How can you get this field ?
Answer :
Create new Win32 console application via MS Visual C++ 6.0 and set Project Properties to write code for Lotus Notes
Include main/necessary include files.
(You can find Notes C API toolkit from IBM web site and also there are more samples to find solution)
in the main function. Initilize notes using
/* Domino and Notes initialization */
if (error = NotesInitExtended (argc, argv))
{
printf("\n Unable to initialize Notes.\n");
return (1);
}
Then get target database. You can use this function.
DBHANDLE LNPUBLIC GetDatabase (char *chrFullPathName)
{
DBHANDLE hCustomDB = NULLHANDLE;
STATUS nError = NOERROR;
// Get Database - STARTED
if (nError = NSFDbOpen (chrFullPathName, &hCustomDB))
{
PrintAPIError ("GetDatabase", nError);
return (NULLHANDLE);
}
// Get Database - FINISHED
return (hCustomDB);
}
Usage :
DBHANDLE hDB;
hDB = GetDatabase("CN=APPDEV01/O=BESTCODER!!Sample.nsf");
or
hDB = GetDatabase("C:\Lotus\Notes\Data\Sample.nsf");
then;
Get target script library (Note)
// ---------------------------------
NOTEID IDLSNote;
NOTEHANDLE hLSNote;
WORD wRetLen;
char szFieldValue[DESIGN_FIELD_MAX+1];
char chrElementNam[DESIGN_FIELD_MAX+1];
nError = NIFFindDesignNote (hDB, "LS Library Note Name", NOTE_CLASS_FILTER, &IDLSNote);
if (nError != NOERROR )
{
return FALSE;
}
nError = NoteOpen (hNoteVERSION, IDLSNote, &hLSNote);
if (nError != NOERROR )
{
return FALSE;
}
wRetLen = NSFItemGetText(hNote, "$ScriptLib", szFieldValue, (WORD) sizeof(szFieldValue));
sprintf(chrCodes, "%s", szFieldValue);
// Now you have LS Library procedures in chrCodes
NSFNoteClose (hLSNote);
NSFDbClose (hDB);
// ---------------------------------
I hope, this post will help you to find solution. And sorry, it covered big area on this page.
Regards,
Ferhat Ikbal BULUT
www.bestcoder.net




