Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quotation marks around string variable in View.ftsearch

Status
Not open for further replies.

Oshanter

Technical User
Feb 1, 2018
5
0
0
GB
Hi,

I have not developed a Notes app for a few years and I am very rusty. I am trying to read a file using the "Open for input" and Input #filenum method then pass the string variable to a View.ftsearch. I know that the string has to be wrapped in quotation marks but cannot get it to work. the search always returns 0 docs in the collection. I know the string works when I put a variable wrapped in quotes from the View.ftsearch("text" , 0). I know that it can be done , but I cannot remember how to do it, nor can I find any solutions on line. Thus I throw myself on the mercy of you guys.


Please ignore the other stuff, this is a "scratch" file to allow me to fiddle with the code
Sub Initialize

Dim sess As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim item As NotesItem
Dim txt As String
Dim nam , blam As String
Dim x As Long
Dim z As integer

Set db = sess.Getdatabase("Tosca", "Names.nsf", False )
Set view = db.getview("($People)" )

Open "c:\temp\glid.txt" For input As 1
Open "C:\temp\faust.txt" For Output As 2
Input #1 , txt

x = view.FTSearch( txt , 0 )

Set doc = view.getfirstdocument()
While Not doc Is Nothing
Set item = doc.getfirstitem("Fullname")
blam = item.contains( txt )
nam = item.text
If blam = False Then Write #2, nam, txt
Set doc = view.getnextdocument(doc)
Wend

Close #1 , #2

End sub

Thanks for the help.

 
Greetings,

If you would allow me, I would suggest you avoid FTsearch. It does work, but the more documents you have, the slower it is.
In this particular case, since you seem to be looking for people in the names.nsf, I would suggest you use the hidden ($VIMPeople) view instead. It is much more practical when you are looking for abbreviated names. The ($People) view has an annoying 1st column showing only the first letter, and that kinda throws things when you want to search properly. I suppose that is why your search is not garnering any results, because there is no special quote requirement - you just need a string variable. Maybe you have quotes loaded from the file, in which case I would strip them out before calling the search. Of course, I am taking as a given that you have indexed the database ;)

With that in mind, I propose the following changes :
Code:
Sub Initialize

Dim sess As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim olddoc As NotesDocument
Dim item As NotesItem
Dim txt As String
Dim nam , blam As String
Dim x As Long
Dim z As integer

Set db = sess.Getdatabase("Tosca", "Names.nsf", False )
Set view = db.getview("($VIMPeople)" )

Open "c:\temp\glid.txt" For input As 1
Open "C:\temp\faust.txt" For Output As 2
Input #1 , txt

x = view.FTSearch( txt , 0 )

Set doc = view.getfirstdocument()
Do While Not doc Is Nothing
[indent]Set item = doc.getfirstitem("Fullname")
blam = item.contains( txt )
nam = item.text
If blam = False Then Write #2, nam, txt
Set olddoc = doc
Set doc = view.getnextdocument(olddoc)
Delete olddoc
[/indent]
Loop

Close #1 , #2

End sub

Keep me informed of your progress :)

Pascal


I've got nothing to hide, and I demand that you justify what right you have to ask.
 
Pascal,

Thank you for your effort on my behalf, I have tried this without success, even using the other view, the FTSearch still requires quotation marks around the variable I have run the agent with a "fixed" variable with quotes, Capture 1 (in the attached DOC1 ) comments 1 and 2 illustrate the variable and the FTSearch returns 2 results. Capture 2 is with the read text file showing the same variable and the results ( comments 3 , 4, 5) with the collection of 0. The third capture is part of the input text file Glid.txt.

So the problem with the quotation marks still exists.

I need help with the FTSearch or an alternative way of find a text string in the address book.

Regards

Tam

 
 http://files.engineering.com/getfile.aspx?folder=d1bc6811-fca9-40a7-9240-c787185e1904&file=doc1.docx
Hello Tam,

Let's try and get you another way. You are looking for J326AHE in People documents. I take that it is a unique ID for an individual. I have seen this in many companies where I consult, because that UNID is then used across a range of applications.
Every time I have come across such a scenario, the names.nsf always had a special view, normally hidden, with People documents sorted by that UNID. If you have design access to the names, you can easily do that. After that, your code can drop the FTsearch and simply do a view.getdocumentbykey(UNID,True).
Be sure to mark that view as not replaceable by design update, otherwise your code will break when the names.nsf is updated.

Regards,

Pascal.
 
Pascal,

Thank you, I went down another route. I imported the data I wanted from Excel using

Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True Set xlwb=xlApp.Workbooks.Open(filename)
Set xlsheet =xlwb.Worksheets(1)

This allowed me to get round the FTSearch by using different approach.

I will keep looking for the answer to the quotes, but I do not need this so urgently now.

Again, thank you for your time and efforts on my behalf.

Regards

Tom
 
Glad you found something that worked.

Don't hesitate to come back if you have any other problem.

Pascal.

I've got nothing to hide, and I demand that you justify what right you have to ask.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top