473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

print from txt file

Oli
Hi,

Ok, last question of the day!

Can I have the contents of a *.txt file simply being printed on a page
(presumably by using response.write)?

Many thanks for all your help today,
Oli
Jul 19 '05 #1
9 2435
Not ~printed~ since that would be something the user would have to do, but
if you mean displayed in the page, you can <!-- #include
file="yourfile.txt" --> it or Server.Execute "file.txt" it.

Those are two options.

Ray at work

"Oli" <ol*@NOSPAMoliwoods.co.uk> wrote in message
news:bq**********@sparta.btinternet.com...
Hi,

Ok, last question of the day!

Can I have the contents of a *.txt file simply being printed on a page
(presumably by using response.write)?

Many thanks for all your help today,
Oli

Jul 19 '05 #2
Also, you could use Scripting.FileSystemObject to open the file and read it
(e.g. if you wanted to parse the contents, or only show certain lines, etc.)

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#p**************@TK2MSFTNGP12.phx.gbl...
Not ~printed~ since that would be something the user would have to do, but
if you mean displayed in the page, you can <!-- #include
file="yourfile.txt" --> it or Server.Execute "file.txt" it.

Those are two options.

Ray at work

"Oli" <ol*@NOSPAMoliwoods.co.uk> wrote in message
news:bq**********@sparta.btinternet.com...
Hi,

Ok, last question of the day!

Can I have the contents of a *.txt file simply being printed on a page
(presumably by using response.write)?

Many thanks for all your help today,
Oli


Jul 19 '05 #3
Hi,

You can do this...

Set myObject = Server.CreateObject("Scripting.FileSystemObject")
Set myTextFile = myObject.OpenTextFile(Server.MapPath("../../textfile.txt"))
While not myTextFile.AtEndOfStream
Response.Write(myTextFile.ReadLine & "<br>")
Wend
myTextFile.Close
Regards,
Bhaskardeep Khaund
Jul 19 '05 #4
> While not myTextFile.AtEndOfStream
Response.Write(myTextFile.ReadLine & "<br>")


Ugh... a loop? Why? How about:

Response.Write Replace(myTextFile.ReadAll(), vbCrLf, "<br>")

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


Wend
myTextFile.Close
Regards,
Bhaskardeep Khaund
Jul 19 '05 #5
Why go line by line? Just readall and replace vbCrLfs with <br>s or use the
<pre> tag.

Ray at work
"Bhaskardeep Khaund" in an HTML message:

You can do this...

Set myObject = Server.CreateObject("Scripting.FileSystemObject")
Set myTextFile = myObject.OpenTextFile(Server.MapPath("../../textfile.txt"))
While not myTextFile.AtEndOfStream
Response.Write(myTextFile.ReadLine & "<br>")
Wend
myTextFile.Close
Regards,
Bhaskardeep Khaund
Jul 19 '05 #6
Hi,

I have used the loot because, if the content of the text file is too big it would be an extra strain on the server. And when using the loops u could format each sentence, leading to more flexibility. I think its a matter of coding style. Whats say?

Bhaskardeep Khaund
Jul 19 '05 #7
Please post in plain text. These HTML attachments are annoying, and so is
having to switch from HTML mode when replying. I think we just found #5007!
Jul 19 '05 #8

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Please post in plain text. I think we just found #5007!


DO IT!
Jul 19 '05 #9
Aaron Bertrand [MVP] wrote:
Please post in plain text. These HTML attachments are annoying, and
so is having to switch from HTML mode when replying. I think we just
found #5007!


LOL - good call.

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Manfred Schwab | last post by:
Recording messages and print statements in a textfile during program execution. Is there a similar command to redirect errormessages or print statements into a standart asciifile during...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
7
by: Ron | last post by:
Hi All, Is it possible to have Access print a report, identical to one that would print to a printer, only print to a "standard" text file? I can't find it in help and when I try to just print...
3
by: Max58kl | last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window -------------------------------------------------------------------------------- Hi I am using a program called...
3
by: itdaddy | last post by:
hey perl gurus! i am new to this forum cause i need help. I have done many scripts. but i want to use perl to do this: What I want to do is this. I have a QRP file that I can convert to a txt...
2
by: alivip | last post by:
when I wont to inser (anyting I print) to the textbox it will not inser it just print then hanging # a look at the Tkinter Text widget # use ctrl+c to copy, ctrl+x to cut selected text, #...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
5
by: prakashturkar | last post by:
Hi, I am Prakash.... I have tried to print an MS Word file using the basic print utilities provided in JAVA.But while asking for printing through my own code i am getting proble for example..."The...
2
by: dmorand | last post by:
When I try to print a 'print version' of my page it looks fine in IE 7, but when I print in IE 6 the margins are all screwed up. The page itself looks the same in both browsers, it's just when I...
11
by: JWest46088 | last post by:
I'm having difficulty trying to figure out how to print a text file from a hash table one line at a time. I have the text file read into the hash table and can print the text file all at once, but I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.