ok, i want my prog to search out for the last string in a text(html) file, and write:
"<br> <a href="notes/(variable goes here)">(variable goes here too</a><br>
how would i go about doing this? questions/comments greatly appreciated.
You will have to read the entire file, line by line checking to see if there is a line after the one that has been read. If there is, write this line to another file and go on and read the next line and check again. If there is not, write out you extra line and then write out the last read in line.
...or you could read the entire file in one operation, find the last line and replace it. Like this...
[tt]
LastLine$ = "<br> <a href=" & Chr$(34) & "notes/"
LastLine$ = LastLine$ & "(variable goes here)"
LastLine$ = LastLine$ & Chr$(34) & ">"
LastLine$ = LastLine$ & "(variable goes here too)"
LastLine$ = LastLine$ & "</a><br>" & vbCrLf
ff = FreeFile
Open "c:\my.html" For Binary As #ff
G$ = String$(LOF(ff), 32)
Get #ff, 1, G$
Cr = InStr(G$, vbCrLf)
For Rep = Len(G$) - 2 To 1 Step -1
If Mid$(G$, Rep, 2) = vbCrLf Then
FoundLast = Rep + 1
Exit For
End If
Next
P$ = Left$(G$, FoundLast) & LastLine$
Put #ff, 1, P$
Close #ff
[/tt]
There are probably many ways you can do this.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.