Approach User Support homepage Approach User Support
Answers to Frequently Asked Questions about Lotus Approach
Examples LotusScripts
Example databases
Links to other Lotus Approach support services

[Return to contents]

Example LotusScript: A "Translate" function in LotusScript

Last updated: 12 Jul 2002

Paul Bent" <paulbent@northwindit.co.uk> writes:

LotusScript is a language implemented in many Lotus products and it doesn't have a built in function equivalent to Translate. Approach product functions like Translate() that can be used in calc fields, macros etc can't be called in a script (apart from a condition in a Find object). You have to write your own parsing function. Something like:

Public Function fReplaceText(Byval strSource As String, _
Byval strOldText As String, Byval strNewText As String) As String
 '--- Replaces all occurences of strOldText in strSource
 '    with strNewText
 '--- Parameters
 '      strSource: the string in which text is to be replaced
 '      strOldText: text to be replaced
 '      strNewText: replacement text
 '--- Return value
 '      returns the source string with the text replaced
 Dim intP1 As Integer   'Position in string
 Do While Instr(1, strSource, strNewText) > 0
  intP1 = Instr(1, strSource, strNewText)
  strSource = Left$(strSource, intP1 - 1) & strNewText _
  & Right$(strSource, Len(strSource)- intP1 - Len(strOldText) + 1)
 Loop
 'Return value
 fReplaceText = strSource
End Function

Then you can call the function from any subroutine, eg:

CurrentView.Body.fbxFirst.Text = fReplaceText(CurrentView.Body.fbxFirst.Text, "A", "a")

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.