Manage Learn to apply best practices and optimize your operations.

Trim returns and linefeeds functions

This is a non-looping script that cleans up carriage returns/line feeds from text in a field.

I had to export a large amount of data and needed a better and quicker way to remove carriage returns from fields. This is a non-looping script that cleans up carriage returns/line feeds from text in a field. It uses the @ReplaceSubString Formula language function in LotusScript with the Evaluate function. This example uses a field and button on a form. Place the code in a button and change the "myField" reference to a field on your form.

Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument 
Dim strTextToChange As String    
  'field text that will be changed
Dim varModifiedText As Variant   
  'variant container for Evaluate return value
Dim strFormula As String         
  'string to hold formula to pass to Evaluate
Dim strReplacementText As String  
 'the new, modified text

Set uidoc = 

'get field text
strTextToChange = 
uidoc.FieldGetText ("myField")

'get text to replace carriage returns with. 
 I use two spaces here, but can be 
strReplacementText = "  "

'create formula string to use in 
Evaluate function by concatenating 'the 
@ReplaceSubString formula 
text with our variables we created above.
'the pipe is used instead of 
quotes for string literals because quotes are 
part of the string literals.
strFormula = |@ReplaceSubString
("| + strTextToChange + |";@Newline;"| + 
strReplacementText + |")|

'evaluate the formula and store result 
in a variant 
varModifiedText = Evaluate(strFormula)

Msgbox strTextToChange, 0+64,  
"Your text to change: "
'note that variant "varModifiedText"
 is an array Msgbox varModifiedText(0), 
0+64, "Your new modified text: "

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member Joe Steblay. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...