×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Quotation marks around string variable in View.ftsearch

Quotation marks around string variable in View.ftsearch

Quotation marks around string variable in View.ftsearch

(OP)
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.

RE: Quotation marks around string variable in View.ftsearch

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
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
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.

RE: Quotation marks around string variable in View.ftsearch

(OP)
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

RE: Quotation marks around string variable in View.ftsearch

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.

RE: Quotation marks around string variable in View.ftsearch

(OP)
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

RE: Quotation marks around string variable in View.ftsearch

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close