Call 'Recompile all LotusScript' option from LS or Java
View member feedback to this Ask the Expert Q&A.
Is there a way to programmatically call the "Recompile all LotusScript" option from LotusScript or Java? We are in the process of upgrading all of our applications to R6 and want to recompile the LotusScript on each database to validate the codes inside each design element. It would save us a lot of time if we can loop through all the databases on the server and call on this option to recompile all of the LotusScript.
There isn't a single command to compile an entire database, so you would need to write code to loop through all forms, script libraries, agents, etc,. and compile them one-by-one. It can be tough to write this kind of code, but it should perform well, since API code runs at the operating system level and is very fast.
Below is the description of the NSFNoteLSCompile function from the API reference.
NSFNoteLSCompile - Compile a note containing LotusScript modules.
-------------------------------------------------------------------------
#include <nsfnote.h> STATUS LNPUBLIC NSFNoteLSCompile( DBHANDLE hDb, NOTEHANDLE hNote, DWORD dwFlags); Description : The API compiles all the LotusScript code found in a design document. This includes document classes such as Views, Agents, Forms, Pages, Navigators, Shared fields, script libraries, Help documents, using database documents, etc. It is a way of making sure that the object code of the script is up-to- date. For the Agent note, the compiled object code is saved in the $AssistAction_Ex item. Parameters : Input : hDb - Handle to the database. hNote - Handle to the note containing LotusScript modules. dwFlags - (Reserved for future use) Must be 0. Output : (routine) - (routine) - Return indicates either success or what the error is. The return codes include: NOERROR - Operation was successful. ERR_NULL_NOTEHANDLE - if hNote was not specified. ERR_xxx - STATUS returned from a lower level Notes function call. Sample Usage : ... /* Compile the Agent note */ if (error=NSFNoteLSCompile(hDb,hAgent,0)) { printf("Error: LS Compilen"); goto Exit1; } /* Update the note */ if (error=NSFNoteUpdate(hAgent,0)) { printf("Error: can't update note after LS Compilen"); goto Exit1; }
MEMBER FEEDBACK TO THIS ASK THE EXPERT Q&A:
The exception I have to the answer for this question is that Brad was all too happy to answer the technical question without addressing the reason for the question being asked.
Compiling actually changes code, unlike signing, and if your company has rules about changing code on a production system without going through development phases, that should give you some direction. Besides, if a problem occurs with recompiling a production database, you now have a production system with a problem! If this were able to be done programmatically, you could have a huge mess on your hands the next morning.
I have seen Domino Designer save LotusScript without raising an eyebrow, and then have the "Compile" feature throw an error. I have run the "Compile" feature and gotten errors on databases that have otherwise been working fine for years. I have had the "Compile" feature completely lock up my Designer client if there are too many circular dependencies in script libraries -- in code that ran fine in production! Compiles are not something to be taken lightly and are tools for developers -- not a maintenance task like Compile, Fixup, or Updall.
—Kieras David J.
Do you have comments on this Ask the Expert question and response? Let us know.