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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

objDocument.WriteLN Option

Status
Not open for further replies.

lpb71

Technical User
Mar 10, 2004
57
GB
My script below looks a a file and displays the size ad it is increasing. However on the iexplorer page it is scrollong up the screen and making it dissicult to see the file size changing. see example below


Replicating Data to USB Device. Please Wait....
File Size so far =11526144 bytes
File Size so far =25841664 bytes
File Size so far =25862144 bytes
File Size so far =40312832 bytes
File Size so far =40329216 bytes
File Size so far =54444032 bytes
File Size so far =54460416 bytes
File Size so far =69074944 bytes
File Size so far =69095424 bytes
File Size so far =83304448 bytes
File Size so far =83324928 bytes
File Size so far =97705984 bytes
File Size so far =97722368 bytes
File Size so far =112295936 bytes
File Size so far =112316416 bytes

Is it possible to limit the "File Size so far = ???" line to 3 lines rather than it keep scrolling up the screen.

Part of my script is below.







Set objExplorer = CreateObject("InternetExplorer.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 400
objExplorer.Height = 200
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible=1

do While (objExplorer.Busy)
Loop

Set objDocument = objExplorer.Document
objDocument.Open
objDocument.WriteLn "<html><head><title>LREP Data Replication</title></head>"
objDocument.WriteLn "<body bgcolor='white'>"
objDocument.WriteLn "Replicating Data to USB Device. Please Wait....<p>"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("b" + (branchid) + "sr01.0")

FileSize1 = (objFile.Size)
wscript.sleep 10000
FileSize2 = (objFile.Size)


Do Until FileSize1 = FileSize2
objDocument.WriteLn("<html></body>File Size so far =" & (objFile.Size) & " bytes <br>")
FileSize1 = (objFile.Size)
wscript.sleep 10000
objDocument.WriteLn("<html></body>File Size so far =" & (objFile.Size) & " bytes <br>")
FileSize2 = (objFile.Size)
Loop
objDocument.WriteLn "<br>Replication Complete."
objDocument.WriteLn"</body></html>"
wscript.sleep 4000
MsgBox "Replication Complete"




 
You could load the generated HTML into an iFrame or a DIV with a fixed size and overflow set to auto.



What's going on here?
Code:
objDocument.WriteLn("<html></body>File Size so far =" & (objFile.Size) & " bytes <br>")

The HTML is syntactically incorrect.
Fixing what you are outputting might solve your other problems too.

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Ham and Jam - British & Commonwealth forces mod for Half Life 2
 
My HTML line works fine.
Not really - it definately won't validate.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Which bit is wrong, Just cut and paste line from my script, which does write the line in an explorer screen.

objDocument.WriteLn("<html></body>File Size so far =" & (objFile.Size) & " bytes <br>")
 
My HTML line works fine.

OK. So looking at your code and getting the HTML output from it I see the following.

You open an <html> tag - good start
Open <head> tag - yes
You open a <title>, close it again - cool
You close the <head> and open a <body> tag - excellent
Then you output some stuff that first open another <html> tag - ummm
then you close your <body> tag - huh?
Now you ouput your string showing the filesize.

Then you close the <body> tag - once more, to be sure
and finally close the <html> tag - good finish


So, no. Your HTML is not actually correct is it?
Half way through the document you kind of start again and close it, before showing the info you want to show.
I'm not saying that fixing your HTML will fix the problem but it would certainly rule out the possiblity that IE is fouling up on your syntactically incorrect HTML. It's basically guessing on how to parse the document.

Try getting the document structure right, then output the file size info into an iFrame or a DIV with a fixed height.

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Ham and Jam - British & Commonwealth forces mod for Half Life 2
 
I should add that an HTML file should follow this basic structure.

Code:
<html>
<head>
<title></title>
</head>
<body>
.. stuff here ...
</body>
</html>

Whereas you have

Code:
<html>
<head>
<title></title>
</head>
<body>
[COLOR=red]<html></body>[/color].. stuff here ...
</body>
</html>

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Ham and Jam - British & Commonwealth forces mod for Half Life 2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top