Evaluate, the bridge between Lotus Script and @Formula

In lotus notes programming, I usually use Formula for simple program and Lotus Script for more complex program. I try to avoid many lines of Formula, because it difficult to read and not structured.

But, Formula have many method that Lotus Script do not have, like @Implode and @Explode. Even we can write our ownLotus Script function to do that, it just a waste of time and energy.

But, we have Evaluate in Lotus Script.

Evaluate  function is one of many of my favorite functions, because it able to run Formula and than pass the result of that Formula intoLotus Script variable (variant).

This is the syntax of Evaluate

variant = notesSession.Evaluate( formula$, doc )

We can use Evaluate function to pass the result from any kind of Formula,  from simple formula like @UserName to more complex formula like @Implode.

Recently, I use Evaluate in my program, to shorten the length of theLotus Script.

I need to calculate the difference in days between two date, but only in business days ( so saturday and sunday will not be counted also holidays).

Formula already have the function to calculate that, so I don’t need to create another lengthly Lotus Scriptfunction just to calculate that. I use the formula instead, so I need the Evaluate function.

varDay=Evaluate(“@BusinessDays(@Date(datFinal);@Date(@Now);1;datPublicHoliday)”,doc)

Remember that Evaluate function return value is variant.

With Evaluate, Formula and Lotus Script can coexist together.

5 thoughts on “Evaluate, the bridge between Lotus Script and @Formula

  1. workaround says:

    The following fails
    Dim Doc As NotesDocument
    Set doc = db.CreateDocument
    ‘ … more code to do something
    Dim intLength As Integer
    intLength=Cint(strLength)
    resnamecheck=Evaluate({@Adjust(@Now;0;0;0;intLength;0;0)},doc)

    here’s a workaround..

    Dim Doc As NotesDocument
    Set doc = db.CreateDocument
    ‘more code…
    Dim intLength As Integer
    intLength=Cint(strLength)
    doc.intLength=intLength
    resnamecheck=Evaluate({@Adjust(@Now;0;0;0;intLength;0;0)},doc)

    basically put the variable inside doc and it will work..

    This shows how to use a Lotus variable in evaluate and get around the limitation
    (please remove previous post)

  2. Sheryl Banks says:

    @workaround

    Hi, I’m missing the difference between what you said failed and your suggested workaround code. Can you point out it out please? Thanks

  3. bfebrian says:

    @Sheryl Banks:
    The fails one:
    Dim intLength As Integer
    intLength=Cint(strLength)
    resnamecheck=Evaluate({@Adjust(@Now;0;0;0;intLength;0;0)},doc)

    The workaround:
    Dim intLength As Integer
    intLength=Cint(strLength)
    doc.intLength=intLength <-- he added the variable inside the doc resnamecheck=Evaluate({@Adjust(@Now;0;0;0;intLength;0;0)},doc)

  4. bfebrian says:

    @Sheryl Banks:
    because the formula can’t read the variable from the lotus script, so we need to pass the variable via notes document.

Leave a Reply