LNText

My favorite tool is LNText. Don know if i can call it a tool though !
It’s a script Library I use almost every where i code something in Lotus Notes. Why do i use it all the time? Maybe you have heard of it before, so its not a thing that i have invented, and you can find it different places on the Internet.

It does the same as array, but its just a lot easier, because you don’t have to care about redim etc.

Let med give you an example.

If you have a multi value field, you can put it in to a LNText, and then I can use the LNText to check, modify, alter etc.

This is how I do it.

Option Declare

Dim mvField as New LNText()
…set doc
call mvField.setValue(doc.getItemValue(“mvField”))

There can be 1,2 or a 100 entries in the mvField, but that doesn’t matter, LNText takes care of if.

So if I want to print the entries out

Dim i as integer
For i=1 to mvField.getCount()
msgbox mvfield.getElement(i)
Next i

By the way – Always use doc.getItemValue(“FieldName”)(0) and not doc.FieldName(0).

getItemValue always returns something, even if the field doesn’t exits, as doc.FieldName(0) returns an error if it doesn’t exits.

But be aware – in Lotus Notes java code, it doesn’t do that any more. Previously all the core Notes classes behaved the same, but with this function it doesn’t. I’ll properly blog about that some time, and for now you can read about it in the help database. So be aware when you upgrade.

And if I want to change a single value of the mulit value field. I can do this.

Option Declare
Dim mvField as New LNText()
Dim i as integer
…set doc
call mvField.setValue(doc.getItemValue(“mvField”))

For i=1 to mvField.getCount()
If mvField.getElement(i) = “the value i want to find”
call mvField.setElement(i) = “the new value”
End if
Next i

call doc.replaceItemValue(“mvField”, mvField.getValue)

I this ex i have loaded the multivalue field into a LNText, ran through it, changed a value, and written it back to the doc. Very simple, and for me thats the easies way to do it.
And if you want to put an extra value to it, you can just use.

call mvField.append(“extra value”)
call doc.replaceItemValue(“mvField”, mvField.getValue)

No redim, no nothing, just one line

I have used a long time, so I know all the functions by heart. Read through all the functions, and see what it can do.

And I’m sure you will learn to love the features of LNText()

I also have a Java version of it, that behaves the same way. You can find them both on my resources page.

Enjoy

This entry was posted in Lotus and tagged , . Bookmark the permalink.