Solved

@ReplaceSubstring equivalent in LotusScript.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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 …

911 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

25 Experts available now in Live!

Get 1:1 Help Now