Click to See Complete Forum and Search --> : modifying text??
Pooter8D
06-18-2003, 08:09 PM
hi, quick Q.. i'm using a text file to store info for part of a forum that i am editing and adding and appending new information to that txt file using forms and asp is working great for me, but lets say i want to delete a certain item from the txt file, how can i accomplish this with a checkbox to select that item??? Basically i can do the selection part but i am unfamiliar on how to get delete the stuff in the txt file once i loop to get to that point.
ex:
TXT FILE
a
b
c
d
----------------
FORM
Delete? Letter
- a
x b
- c
Submit
----------------
Once i click submit i will want letter b to be deleted from the txt file while others preserved and moved up a line
NEW TXT
a
c
d
Thx :)
Pooter8D
07-09-2003, 03:22 PM
hmmm thx for ur reply.. its been a while but i finally got some time to test it out.. but there must be something that i missed or dont understand.. here is my code:
dim FS, File, txt, str
dim LinkToDel
set FS = Server.CreateObject("Scripting.FileSystemObject")
set File = FS.OpenTextFile(Server.MapPath("links.txt"),ForAppending,true)
'Init variables
LinkToDel = Request.Form("LinkToDel1") 'gets form word
Set File = Nothing
Set FS = Nothing
As u can see this code is not complete becuase what u recommended
txt = objOpenFile.ReadAll
the readall is not a function of FS or File
i also tried spliting it up like so.. but that didnt work.. whats up??
Set File = FS.GetFile(Server.MapPath("links.txt"))
Set OpenFile = File.OpenAsTextStream(ForWriting)
txt = OpenFile.ReadAll
but OpenAsTextStream is also not a function!
help!
Pooter8D
07-09-2003, 04:11 PM
also how do i go back a dir to save my file??
I have
set File = FS.OpenTextFile(Server.MapPath("links.txt")
saves to ex. ...\abc\links.txt
i want to save to
...\links.txt
but the asp file i'm writing is located at ...\abc\aspfile.asp
Pooter8D
07-10-2003, 09:35 AM
i was reading up on the Left function you had advised me to use and i was wondering.. what is the purpose to find out the number of characters from the left side of the string?? I'm searching for a word but the is no other info on the same line. So once it finds the word... it should delete the line. The example i used up in my 1st post was just a simple example for what i had to do.. i guess it was my fault when i told u i just wanted to get rid of a letter.. but now going back to the Left function.. is it needed anymore??
1 more thing.. i want to loop TD creation..With Links
Is this possible??
<%
do while File.AtEndOfStream = false
LN = File.ReadLine
HTTP = File.ReadLine
File.SkipLine()
%>
<td width="25%" align="left" class="text" background=#ffffff><a href="http://link.com">link</a></center></td>
<%
loop
%>
I dont think that can work.. how can if possible.. i do this?? :confused:
thx Dave for all your help :)
Pooter8D
07-10-2003, 11:11 AM
ok i figured out the deleting... its more of a pain since asp doesnt have a delete fucntion.. so i had to create a temp file and overwrite it w/out the string
SearchString = StringToDel
Do until OpenFileIn.AtEndOfStream
Line = OpenFileIn.ReadLine
if Left(Trim(Line),Len(SearchString))<>SearchString then
TempFile.WriteLine(Line)
end if
loop
TempFile.Close
FSO.CopyFile Server.MapPath("../temp.txt"),Server.MapPath("../abc.txt"),true
FSO.DeleteFile(Server.MapPath("../temp.txt"))
that seemed to work fine.. but still the question of the looped table creation remains