Solved

@ReplaceSubstring equivalent in LotusScript.

Posted on 2004-08-24
3
449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 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