Solved

@ReplaceSubstring equivalent in LotusScript.

Posted on 2004-08-24
3
441 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Lotus Notes 8.5 1 149
Lotus notes email code 2 122
Updating Lotus Notes workspace icons with new server 1 130
Lotus Notes shared mailbox 'Sent by' in header 3 74
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 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