Solved

@ReplaceSubstring equivalent in LotusScript.

Posted on 2004-08-24
3
435 Views
Last Modified: 2013-12-18
Hi,

I've the following code in my agent

Let Cnam = Trim$(doc.Custname(0))
Let CIAccount$ = Ucase(Cnam)                  

Set Collection = db.getView("*Counts\CBCN").getAllDocumentsByKey(CIAccount$)
If Collection.Count = 0 Then                          
     'Display MessageBox    
Else
    'Do Processing
End If      


Now In the view "*Counts\CBCN"  I've the first column as the following: @ReplaceSubstring(@UpperCase(@Trim(CustomerName)); " "; "+")
I'm replacing all spaces with +.

Now I've to do the same in CIAccount$.

Lets say if the user enters "IBM Data Services Inc" in the doc.Custname(0) field in the form
The CIAccount$ will have "IBM Data Services Inc".  I want it as IBM+Data+Services+Inc.

If I do not replace spaces with + here the search will not work.

Now you can tell me that just change the column formula to @UpperCase(@Trim(CustomerName)). But that is not what I want to do here becuase,
Lets say if the User is entering just "AA" in the doc.Custname(0) field and in the view "*Counts\CBCN" I've "AAA - R", It is still considering as a match which is incorrect. I guess it all becuase of the spaces.

Please advise.
thanks
Kalios
0
Comment
Question by:kalios
3 Comments
 
LVL 19

Assisted Solution

by:RanjeetRain
RanjeetRain earned 20 total points
ID: 11883276
Hey buddy,

I have something ready to use for you. This is from my library:




Function ReplaceString(Byval Src As String, Byval Str1 As String, Byval Str2 As String) As String
      If  Src = "" Or Src = Null  Or  Str1 = "" Or Str1 = Null  Then
            ReplaceString = Src
            Exit Function
      End If
      
      Dim beginAt As Integer
      Dim foundAt As Integer
      Dim srcLen As Integer
      Dim repLen As Integer
      
      srcLen = Len(Src)
      repLen = Len(Str1)
      beginAt = 1
      foundAt = -1
      
      Do While foundAt <> 0
            'Msgbox "calling Instr with " & beginAt & ":" & src & ":" & str1
            foundAt = Instr(beginAt, Src, Str1, 5)
            If foundAt > 0 Then
                  Mid (Src, foundAt, repLen) = Str2
            End If
            beginAt = FoundAt                  
      Loop      
      
      ReplaceString = Src
End Function



Good luck!
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 80 total points
ID: 11883293
getAllDocumentsByKey(CIAccount$,TRUE)... the additional parameter specify exact match should be performed on the search.. This will avoid any wildcard searches

~Hemanth
0
 
LVL 2

Author Comment

by:kalios
ID: 11883653
Thanks Hemanth and Ranjeet.

I've used Hemanths. It works great.

Kalios
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now