Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm opening an HTML file and printi

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I'm opening an HTML file and printing code to it, but I would rather it print new entries to the top rather than to the bottom. I know hot to do it in Perl, but can't figure out how in VBscript.

Here is the object I'm opening:

[tt]Set FileStreamObject = CreateObject("Scripting.FileSystemObject")
Set WriteStream=FileStreamObject.OpenTextFile(C:/changed.html",8,True)[/tt]

Then writing to the file with a series of [tt]WriteStream.WriteLine(&quot;<P>Some text here&quot;)[/tt] statements.

By putting into the HTML file a hidden tag something like [tt]<!--BEGIN-->[/tt] and then referencing it as the place to start, it should be able to write from the top down, but I have no idea how to do it. Can anyone help?



Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Hi,
can't you read each line of HTML code into an array then reference it as:
<begin a do until loop adding 1 to x>
if line(x) = &quot;<!--BEGIN-->&quot; then
<insert code here>

then knowing the value where x stopped at - continue writing from that point onwards

Not sure at all if that helps

Regards,

Jim
 
Hi Jim,

Thanks! Yes, that's what I was looking for, though I am not sure exactly how to incorporate it into the WriteStream lines. I guess I would put this in below where the file is being referenced, then &quot;End if&quot; the whole thing when it's all done. Is that right? I have done virtually nothing of this kind of thing but it looks pretty straightforward so I'll try it when I'm back at the office tomorrow.

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Well, I tried it but really don't know enough to get it to work since I'm not really sure of the sytax for the looping. Also, don't I need some value for &quot;x&quot;? Otherwise, I get a &quot;Type mismatch 'line'&quot; error. Here's what I have:

Code:
Set FileStreamObject = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set WriteStream=FileStreamObject.OpenTextFile(changed.html&quot;,8,True)

do while not eof
   if line(x) = &quot;<!--BEGIN-->&quot; then

WriteStream.WriteLine(&quot;<b>&quot;)
WriteStream.Write(now())
WriteStream.WriteLine(&quot;</b>&quot;)
WriteStream.WriteLine(&quot;<br>&quot;)
WriteStream.WriteLine(&quot;The following record has been &quot; + &quot;<i><b>&quot; +request.QueryString(&quot;Updated&quot;) + &quot; </b></i>&quot; + &quot;:&quot; + &quot;<br>&quot;)
WriteStream.WriteLine(&quot;Record ID: &quot; + &quot;<b>&quot; + request.QueryString(&quot;MM_recordId&quot;) + &quot;</b></a><br>&quot;)
WriteStream.WriteLine(&quot;For: &quot; + &quot;<b>&quot; +request.QueryString
WriteStream.Close
loop
End if

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Can anyone help me here with the above problem?

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top