Question

I have a lotus script field in my form build using Domino Designer. This field allows user to store Lotus Multi-Byte Character Set string as well. However i want to convert this to an ASCII string. I always used the @Ascii() function in formula language to convert it in my view column defination. However i plan to do this in the Exiting() function in lotus script Can someone please help me to do a similar operation in lotusscript ?

Formula Language

@Ascii(@Text(Employee_Name)) 

LotusScript:

Sub Exiting(Source As Field)

    Employee_Name = Asc(Employee_Name)  // does not work

End Sub
Was it helpful?

Solution

First of all: there is one big error in your question: there is no "LotusScript- field" in Lotus Notes. All editable fields have LotusScript- Events, but the main language for fields is Formula. With formula you can define Default- Values, Input- Validations and -this is important for your question- Input- Translations. The Input- Translation- Event can contain formulas to transform the content of the field before storing it.

Of course you can write these 10 lines of code in QuerySave. But you can also just put this formula in the input translation of the field:

@Ascii( @ThisValue )

It's your decision...

OTHER TIPS

You could use the Evaluate statement to call the @Ascii formula:

Sub Querysave(Source As Notesuidocument, Continue As Variant)

    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim doc As NotesDocument
    Set uidoc = workspace.CurrentDocument
    Set doc = uidoc.Document
    Dim eval As Variant

    eval = Evaluate("@Ascii(@Text(Employee_Name))", doc)

    Call doc.ReplaceItemValue("Employee_Name", eval)

    Call doc.Save(True, False)

End Sub

If the other solutions are not acceptable for any reason then you can use LS. The issue with Asc (and Char) is that it works on a character at a time. Simply loop over the field value and convert each character one at a time, and then append each back to a string (or write the ASCII value to a byte array). You might also find the 'byte' versions usefull too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top