Read Last Line In Textfile
I wuz just wondering, whats the easiest way to read a text files last line...
I know i have to count the lines and put pointer to the last line and read from there.. but i cant get the hang of it
heres my code:
I wuz just wondering, whats the easiest way to read a text files last line...
I know i have to count the lines and put pointer to the last line and read from there.. but i cant get the hang of it
heres my code:
Alright im tryin 2 write 2 a text file and then read from tat text file on the same page is this possible this is what i got so far. Code:
View Replies View RelatedI had created a macro to read data from an excel sheet and write the values to a text file. I had used "ActiveSheet.Range("GB" & k).Value" command to read the values from the excel.some cells in the excel sheet is having two lines value and four lines data, the text file is generating that value in a single line. (Ex. the cell value in address column is in four lines and should display in four lines in the text file generated from the macro)
Can i do something in the excel sheet or in vb script to read the address value line by line and write line by line in text file?
I have an encrypted .txt file created by asp. Its formatted with lines etc. Title followed by description underneath. I need to read this into ASP now, and parse it line by line. On each line read, run the function to unencrpt and add line to a new file.
Its the line by line Im having trouble with. If i do the full textstream no formatting takes place coz im adding the fulltextstream all in one addline call. How can I loop through lines ?
I would like to know which ad is being presented through adrotator, so that I may write out some comments about the image presented. Would I use FSO to determine which line of code from the text file is being presented? If FSO is the answer, what would it look like?
View Replies View Relatedi wrote this code to read the datas from excel(.csv file). but it read all the datas as 1 line. i don't undestand why.is there any function that i can use to stop it read the datas in the next line?? can anyone help me?? thanks a lot.
Do While Not TextStream.AtEndOfStream
line = TextStream.readline
if line <> "" then
arr_User(i) = trim(line)
splitline = split(arr_User(i), ",")
for j=0 to 5
response.Write splitline(j) &"nbsp;nbsp;"
next
i = i + 1
redim preserve arr_User(i)
end if
Loop
I have a log file from my email software program. Each entry is on a line and the values are seperated by tabs. How can I read through this text file such that I insert its contents into a database? Thanks. Tom
Here is one entry from that file:
11/30/06 00:00:21SMTP-IN25AA24076F2041D7B35E97EE7748D06C.MAI65284.244.91.208EHLOEHLO [84.244.91.208]250-home [84.244.91.208], this server offers 4 extensions11922
I would like to know how can I open a textfile from other website like www.website.com/jhon.txt.?
I want to open it in my default.asp, without remove my banners and buttons and all my Images, Im just want to open it in the middle of my asp page. How can I do that?
I cannot append to a textfile. This is my sample code:
set f=Server.CreateObject("Scripting.FileSystemObject")
set obj_log .CreateTextFile"C:loglog.txt",true)
obj_log.WriteLine("Added schedule by [Name]")
f.close
obj_log.close
Set obj_log=Nothing
Set f=Nothing
The problem is the next time i execute these lines from an asp page, it does not append in a new line. I cannot figure out how.It just keep on overwriting.
i need a asp script out there for a guestbook. all the form input will be stored to a normal txt file, not a database. anyone have any links out there for this ? i have found a couple, but got errors when setting them up and it's been the script, not the server.
View Replies View RelatedI cannot use the OpenTextFile method, it's never return and I get no
error message! Setting Response.Buffer=False, has no effect. No matter
if I use it ForReading or ForWriting, it never return. In the following
code, the problem occurs at line 3.
aFileName = Server.MapPath("WEB_PROD.htm")
set fs = server.CreateObject("Scripting.FileSystemObject")
set fso = fs.OpenTextFile(aFileName, ForReading, False)
s = ts.ReadAll
ts.Close
set ts = nothing
Response.Write s
i want to create atext file using asp(filesystemobject but my explorer hangs on. Why?
View Replies View RelatedI am currently writing a script for a course i am doing, It lists all the files and folders on the server, and works similar to windows explorer ( if you click on the folder it shows the content ). I have enabled it so you can delete, view source, and download all files/folders.
Now theres one more thing i would like to do, and that is to enable the user to edit a file, and i am struggling quite a bit, any guidance, ideas or links to a similar tutorial. I am probably going about it completley the wrong way, I was trying to open the file read each line and write it into a textarea, so the user could edit it, and then save it.
With the following code I can create a new textfile if it does not exist, but it seems impossible to me, to append data to an existing file.
Dim objOpenFile, objFSO, strPath
StrPath = Server.MapPath("../smslog.txt")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(StrPath) Then
Set objOpenFile = objFSO.OpenTextFile(StrPath, ForAppending)
Else
Set objOpenFile = objFSO.CreateTextFile(StrPath, True)
objOpenFile.WriteLine "KundNr;Namn;Datum;Tid" 'header
End if
..
..
what I have done wrong?
I'm trying to make a text file search that will read a text file looking for the string the user typed in, then if it finds the string i want it to display all the information on that line then continue it's search through the rest of the file repeating the previous step if needed.
What i've got so far is it reading the text file in and it can search for a particular string(word, name etc) and say whether or not its in the file, but i don't know how to get it to display the whole line of information and continue it's search.
I read a text file in ASP using readline. The line is stored in a variable. I want to be able to search that line for a specific word.
How do I go about this?
After I've performed a query and held the data in a RecordSet (rsQuery), can
I dump the recordset into a comma separated text file? How?
I'm pretty new to webprogramming. I use VWD 2008 Express Edition.
I try to build a webpage and the content of that page is stored in a
textfile on the filesystem. That way I can change the content of my webpage
very easy. The problem is that I can't figure out how to show the content of
that textfile in my browser.
I have this textarea and I inputted this;
Quote: asp
xml
xhtml
If I update/save this to a database(msaccess) and view this in a browser it gives me a one line record like;
Quote: asp xml xhtml
but I dont want to put every end of the line a <br> tag for me not to view a one line record, how do I do this?
PHP has a function called nl2br() which inserts HTML line breaks before all newlines in a string. Is there an ASP equivalent to this?
View Replies View RelatedI've managed to code a function that will straightly replace some given character to another, for security of my pages. For example, I can convert (") to " and (') to ´ ..etc in the form(text field) that allow user to post some data to be stored in the db. But then I don't want the user to write it in HTML tag, and I want that when user press [Enter] on the keyboard, then I can redisplay the message in the way that the user really type in (new line). What I'm thinking is if I can replace the [ENTER] pressing to <br> to be stored in my db. But I didn't found the way I can do that.
/n such as in c++ didn't solve. Anybody knows? I use ASP VBscripts/
Does my question clear?
I have this small 4 line PHP code and I would really like this to work with ASP, can anyone dp this for me?Code:
<?php
$tempVar = 'http://www.temp.com';
$feed = file_get_contents($tempVar);
header('Content-type: text/xml');
echo $feed;
I am trying to trap my ASP errors using the ASP error object.
Everything works almost fine, but I can't retrieve the line number where
the error occured. Here is a little piece of my code:
==========================
If Err <> 0 Then
Response.Status = "500 Internal Server Error"
Response.Expires = 0
Dim ErrorContent
ErrorContent = ErrorContent & "Description: " & Err.Description & vblf
ErrorContent = ErrorContent & "Line: " & Err.Line & vblf
ErrorContent = ErrorContent & "Number: " & Err.Number & vblf
ErrorContent = ErrorContent & "Source: " & Err.Source & vblf
What does this line mean?
streamFile.SaveToFile m_sUploadFolder & fileItem.FileName, 2
in my textbody, i have several fields to send as an e-mail, but they would not fit into one row, how could put on the other line in the text body e-mails my other fields, thanks
#
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mail@mail.com"
myMail.To="mail@mail.org"
myMail.TextBody = "comment " & request.form("comment") & "; " & "city " & request.form("city")
myMail.Send
set myMail=nothing
/#
1. I have a form that insterts data in a database
2. I show this information in a pop-up page
3. When the user enter too much content it makes all the
pop-up too widther and it breaks the design.
I want determinate a specific number of caracters and then
do a line break.
I guess I need something like this:
replace(sql.field,char(10),'<br>')
in the way I show my content
like this:
<%=rs.fields("nombre").value%>
How can I do it?
Im developing a site for an organisation im a member of. Im trying to make updating the site a simple as possible for the organistions staff, some of which are not the computer literate. So i have made a kind of template site where the content of all the pages held in a access db. I have then made an admin backend where organisation staff can login and update the contents of pages simply by editing text in a text box and clicking the update button.
However, i've come across a problem. When users leave a line break in the text box the output page doesnt display the gap. I am using a simple response write to display the contents of the attribute on the page. Currently the only way im managing to get line breaks is to enter a '<br>' into the text box on the admin page.
How could i make it so when a line is left blank on the text box the database records this and displays it on the output page?
How do I Comment a line in asp
View Replies View Relatedi have a variable which is like
Code:
UsrStr = "root|1234"
ive checked the text file for it to validate it for removal, if it returns true i need to remove the line and clear that line so new lines can be added in the future.
how can i remove a spcified line from the file?
We've built a page that allows users to enter items that will ultimately
become a list. One particular user enters them into the textarea on the
page and for some reason always puts a hard return into the textarea before
she submits. This goes into SQL as a line break and it's screwing up how
the page renders.
How do I find this via code so that I can replace it? I've tried looking
for chr(13) + chr(10) and vbCr and vbCrLf and replacing them with "" but it
doesn't seem to work. Am I missing something?
I'm trying to save to a message field with the field type, memo.
Say I save the message:
"Test 1
Test 2
Test 3"
When I response.write it, it will turn out like " Test 1 Test 2 Test 3"
losing all the line breaks and such
If I response.write it within <textarea> </textarea> tags it comes back
Any One Has Any Idea How To Draw A Vml Line Graph ?
View Replies View Relatedif x=1 then response.write("A Man walks into a bar. Ow!")
the following ASP VBscript returns the following text:
"A man walks into a bar. Ow!" (minus the " marks)
How do I make it return the text:
"A Man walks into a bar.
Ow!"
(notice the line break)