What goes where in a Script Library

First of all, I know virtually noting about script… just Formula so please excuse the dumb question…

I am trying to put the following “OnChange” code into a script library so I can use it in multiple places. I created the library but I do not know what goes where… Library name section - (Options) - (Declarations) - Initialize - Terminate. Any help would be appreciated… Thanks, Paul

Sub Onchange(Source As Field)

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument



docdate = uidoc.FieldgetText("BIOrderApprovedDisplay")

If CDat(docdate)>CDat("10/01/2013") Then

	Call uidoc.FieldSetText("BIMfgSocketTotal", CStr(CInt(uidoc.FieldGetText("BIBQuantity")) * CInt(uidoc.FieldGetText("SockPerBIB"))))

End If

End Sub

Subject: Script Library

Your functions goes into the script library as stand-alone functions, so after the Initialize.You then call those functions from other scripts in your application.

Also, I would not just copy the Onchange sub like you do. Never give yoru own functions or sub routines the same name as built-in functions in Lotusscript. In addition, since you don’t use the variable Source, there is no need to pass it to the sub routin.

You may want to look at some books or online resources to learn more aboiut Lotusscript. I learned plenty from the old Yellowbooks that came with Notes 4.x and 5.0 (still got them!), and the Notes 6.0 Redbook is also very good:

http://publib-b.boulder.ibm.com/abstracts/sg246854.html

It will be much easier if you understand things like functions and subroutines, branching, data types, etc. Lotusscript is very similar to ealrier version of Visual Basic, so if you ever worked with VB, you should feel at home when it comes to the actual language and syntax.

Subject: Thanks

Thanks Karl, when I have more time, I’ll give this a go.

Take care, Paul