Searching a Flat File
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=13981
Printed Date: 30 March 2026 at 1:11pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Searching a Flat File
Posted By: wolfie
Subject: Searching a Flat File
Date Posted: 24 February 2005 at 12:56pm
My website, http://www.wolfweb.co.uk - WolfWeb.zero is made using a flat file system. My flat file system works on one page of ASP that is split up using
if Request.querystring("page") = "thisPage" then
Now, I want to be able to search the file for something and then make the search return the page of the right querystring.
So if the search is "blogs" then it finds a piece of text in a page under the request (ie ("page") = "blogs") and so it returns the URL http://www.wolfweb.co.uk/?page=blogs.
My site also runs of a Access backend, so that the blogs, say, are placed dynamically in the page (just like the http://www.webwiz.net/asp/sample_scripts/journal_application.asp - Journal on WWG ) so the search field needs to be able to do that.
So, using that rough guide as to what I want, can anybody help?
Cheers!
------------- Wolfie--[ http://www.wolfweb.co.uk - WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
|
Replies:
Posted By: bootcom
Date Posted: 27 February 2005 at 10:21pm
|
Let me see if I get you ... you want to enter some thing and have it come up with that as a querystring ? So if a user enters blogs you want it to go to ?page=blogs ????
If that is the case, its relatively simple to do.
|
Posted By: dpyers
Date Posted: 28 February 2005 at 12:53am
|
Assuming you've loaded your file into a string called strFileText something like this should work...
strStartFoundWordPos = instr(strFileText,request.querystring("page")) strLength = Len(" http://www.wolfweb.co.uk/?page= -
strStartPos = strStartFoundWordPos - strLength
strLength = strLength + Len(request.querystring("page"))
StrURL = mid(strFileText,strStartPos,strLength)
I'm not sure about what else you're trying to do with the access db - e.g. where/when are you going after it after you pull a url. Not Tested -------------
Lead me not into temptation... I know the short cut, follow me.
|
Posted By: wolfie
Date Posted: 28 February 2005 at 11:43am
Well, here's the code to load up a page.
<% if Request.querystring("page") = "thisPage" then %>
This is page 1
<% end if
if Request.querystring("page") = "newPage" then %>
This is a new page
<% end if %>
------------- Wolfie--[ http://www.wolfweb.co.uk - WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
|
Posted By: dj air
Date Posted: 28 February 2005 at 11:44am
or you can uise the elseif command and use
<% if Request.querystring("page") = "thisPage" then %>
This is page 1 <%
elseif Request.querystring("page") = "newPage" then %>
This is a new page
<% end if %>
|
Posted By: dpyers
Date Posted: 28 February 2005 at 12:23pm
|
<% if Request.querystring("page") <> "ThisPage" then
strStartFoundWordPos = instr(strFileText,request.querystring("page")) strLength = Len(" http://www.wolfweb.co.uk/?page= -
strStartPos = strStartFoundWordPos - strLength
strLength = strLength + Len(request.querystring("page"))
StrURL = mid(strFileText,strStartPos,strLength)
Server.Transfer(StrURL)
end if %>
With the above code, if it's not asking for ThisPage, it will pull the proper page info, buld the url, and transfer control to that url.
-------------
Lead me not into temptation... I know the short cut, follow me.
|
Posted By: wolfie
Date Posted: 01 March 2005 at 12:37pm
I'm not picking up how to do this... I rather not put my page in the
form of a string, but outside the ASP area. So simple XHTML.
But will this actully search my site (or flat file) for a certain word
and then pull up the page? Not just if the word is in the querystring.
(I'm still fairly new to ASP so forgive me!)
------------- Wolfie--[ http://www.wolfweb.co.uk - WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
|
Posted By: dpyers
Date Posted: 01 March 2005 at 4:37pm
|
No, I thought you had the words and associated links all in one file so reading it into a string wasn't a big deal.
If you want to search the contents of all files on your site you'll need a more expansive script. Check aspin.com or one of the other script sites for a search script.
Frontpage also has a search component.
-------------
Lead me not into temptation... I know the short cut, follow me.
|
Posted By: wolfie
Date Posted: 01 March 2005 at 4:50pm
Well, had a look around a few script sites and they works mostly on
files. The flat file doesn't work with any that I tried. They return
the default page and not the querystring...
Could it be I am asking too much here?
------------- Wolfie--[ http://www.wolfweb.co.uk - WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
|
Posted By: dpyers
Date Posted: 01 March 2005 at 5:04pm
|
I think we're having a terminology problem.
First I thought you had all the words and links in one "directory file"
Then I thought you wanted to search within all files on your system. My thought now is that all your files are contained within one file - e.g. a flat file system.
Are you using anything specific for your flatfile system - e.g. LDAP - or something from a specific vendor?
-------------
Lead me not into temptation... I know the short cut, follow me.
|
Posted By: wolfie
Date Posted: 01 March 2005 at 5:10pm
Give you the code...
http://www.wolfweb.co.uk/default.txt
Edit: That is all my code, no package was used.
------------- Wolfie--[ http://www.wolfweb.co.uk - WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
|
Posted By: dpyers
Date Posted: 02 March 2005 at 2:00am
|
OK, I think I see what you're trying to do now.
- You have 1 asp page with a bunch of if statements.
- A paticular if statement will execute depending on the value of "page" in the query string.
- Each if statement either writes html directly or queries a data base to get data to write.
- The net reult is that the code to produce all possible pages is within a single page but only one section of page code is executed at a time.
The only way you're going to be able to search all pages is to expand the ones that have data pulled from a db. I'll put together some code to loop through your possible pages for a search term and redirect accordingly.
-------------
Lead me not into temptation... I know the short cut, follow me.
|
Posted By: dpyers
Date Posted: 02 March 2005 at 3:13am
Posted By: wolfie
Date Posted: 02 March 2005 at 6:36am
Dude! You rock! That's just what I wanted!
I owe you a big one.
------------- Wolfie--[ http://www.wolfweb.co.uk - WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
|
|