Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

Re: FN-FORUM Simple Perl Script - ASP Script

date posted 21st August 2000 23:32

Hi Jon

Here's the bare bones of the code that will let you edit a text file. If
you just want the script then jump to the end of the message, as I'm going
to explain how it works. This is all ASP2, and I tested it on PWS on Win98
(I can't be arsed to try it on IIS tonight).

What we use is the FileSystemObject object, which gives us access to the
physical drives and directories on the server.

The first page we'll call reader.asp, this reads the text file that the
client will edit. To do this we create a FileSystemObject object.



We then use this to open the text file we wish to edit as a textstream. We
use the full physical path to the file thus.



This allows us read access to the text file. So we pull all of the contents
of the text file out and stuff them into a variable.



This is all done server side. What we then want to do is to deliver the
file contents to the client and give them the ability to edit them. So what
we'll do is use a form as our client/server interface.






This will create a textarea box on the client side, which will contain all
of the contents of the text file. The user can then edit the contents, add
new contents etc etc to their hearts content. When they're finished editing
it they'll hit the submit button which fires off the contents of the
textarea to our second page, writer.asp.

The first thing we want to do in our second page is get the newly edited
contents from that textarea (forgive me if I'm teaching your grandmother to
suck eggs)



Next we create a new FileSystemObject object.



We then use this to create a new text file on the server (this will
overwrite the old one)



Next we take our variable containing the newly edited textarea content, and
write it to the text file.



Finally we close our object and our work is done.



So the workflow of this is

Read Text File > Write Content to Text Area > Edit Content > Submit Form >
Read Form > Write Text File

If you're any further questions then feel free to ask. Of course I could
have totally the wrong end of the stick and all the people that really know
stuff on the list will flame me now! :)

Norman

Here's the code. The only difference to that above is that I've included
all the HTML to be written within the ASP. This means that all the HTML is
written in one visit to the response object, rather then having to mix an
ASP response.write within the HTML. A good habit to get into.

Reader.asp



Writer.asp





Messages by Day
August 31st 2000
August 30th 2000
August 29th 2000
August 28th 2000
August 27th 2000
August 26th 2000
August 25th 2000
August 24th 2000
August 23rd 2000
August 22nd 2000
August 21st 2000
August 20th 2000
August 19th 2000
August 18th 2000
August 17th 2000
August 16th 2000
August 15th 2000
August 14th 2000
August 13th 2000
August 12th 2000
August 11th 2000
August 10th 2000
August 9th 2000
August 8th 2000
August 7th 2000
August 6th 2000
August 5th 2000
August 4th 2000
August 3rd 2000
August 2nd 2000
August 1st 2000


Messages by Month
December 2000
November 2000
October 2000
September 2000
August 2000
July 2000
June 2000
May 2000
April 2000
March 2000
February 2000


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000