One line @ReplaceSubString for lotusscript

[Update: Read the comments for a better solution with short strings (unverified)!]

Had this problem removing single characters in a string. I don’t like the idea to use strRight() and strLeft() since they can only handle a single entry of the search string.

There are a lot of different solution for this. I have also made my own lotusscript function for @replaceSubString, as every one else. All to complex since Release 6.

Some split and join will do the trick. This is my one liner:
resultStr = join( split( sourceStr, fromStr ), toStr )

The replace is case sensitive.

Example replacing word:
ReplaceSubString Example1

Button code:

Dim ui As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ui.CurrentDocument
Set doc = uidoc.Document
doc.result = Join(Split(doc.text(0),doc.Replace(0)),doc.replacewith(0))

Example removing character:
ReplaceSubString Example2

Or make a function out of it to make it more readable:

Function replaceSubString(sourceStr As String, fromStr As String, toString As String) As String

replaceSubString = Join(Split(sourceStr,fromStr),toString)

End Function

Advertisements

Custom twistie size

A lot to do lately. No time to blog.

But this short tip I’ll manage to squeeze in.

From designer help 7.0.1:

The triangular icons that indicate a row or a section may be expanded or collapsed are called “twisties.” Twisties are green in Notes and blue on the Web. You can customize these icons by importing your own images. You import two images into one graphics file. The first image replaces the “expand” twistie and the second replace the “collapse” twistie. A pair of images for customized twisties should result in a .gif file that is 33 x 16 pixels — that is, two 16 x 16 images, with a 1-pixel divider.

Creating an images with that size will not produce the twisitie look you expect.
Expecting something like this Twistie 33×16 You will get this: Bad Twisitie!

The size does not match. The correct size should be 25 x 12 two 12 x 12 with a 1-pixel divider.