That said:
I have written a simple HTA script that iterates through parsing a text file
by line, incrementing a Progress Bar. But because of the long process the
background disappears if anything overlaps it, and a text <div> is not
updated.
How do I refresh (repaint) the HTA.
NB: The ProgressBar is "of Object" - and not affected:
<object classid="clsid:35053A22-8589-11D1-B16A-00C0F0283628"
id="ProgressBar1" height="20" width="400">
Thank you for any help, and reading through a long winded request.
hi JHP,
Try this:
document.execCommand("Refresh")
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
This pausing your processing for a period of time to give the system
time to update the browser display. This is commonly done through the
setTimeout (or to a lesser extent the setInterval) functions provided
as part of the browser Document Object Model (DOM). The main feature
needed to make this work is that you process MUST take a break at each
point you want the display to be updated. Then the setTimeout kicks
in after the appropriate timeout and restarts the process. This is
pretty tricky to do and somewhat difficult for some people to
comprehend (it took me more than one try ;o).
Anyway, here is a sample I had laying around that illustrates on way
to do it ...
<html>
<head>
<script language=VBScript>
Sub StepWise(nStage)
Dim nPause
document.body.innerHTML = "Step " & nStage
nPause = 500 ' milliseconds
Select Case nStage
Case 1
setTimeout "StepWise " & nStage + 1, nPause, "VBScript"
Case 2
setTimeout "StepWise " & nStage + 1, nPause, "VBScript"
Case 3
setTimeout "StepWise " & nStage + 1, nPause, "VBScript"
Case 4
setTimeout "StepWise " & nStage + 1, nPause, "VBScript"
Case 5
document.body.innerHTML = "Done"
End Select
End Sub
</script>
</head>
<body onload="StepWise 1">
</body>
</html>
This is structured by stages, which by nature do different things. It
could also be a simple IF block around your whole loop process
instead, sometyhing like this ...
Sub Steps(nStep, nLimit)
Dim nPause
nPause = 50 ' milliseconds for example
if nStep <= nLimit then
' do process
' update progress
document.body.innerHTML = "Step " & nStep
else
GoToNextPartofProcess(Arguments, if, needed)
End Select
End Sub
HTH
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
Thank you for replying.
"Tom Lavedas" <tglb...@cox.net> wrote in message
news:23fcad21-b73c-483d...@z72g2000hsb.googlegroups.com...
Sub CreateTMP()
Const forWriting = 2
Const createFile = True
Set objRegExp = CreateObject("VBScript.RegExp")
objRegExp.Global = True
objRegExp.IgnoreCase = True
objRegExp.Pattern =
"[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]"
Set objMatch = objRegExp.Execute(strACHText)
lngRowCount = objMatch.Count
If lngRowCount > 0 Then
strProgress = "<object
classid='clsid:35053A22-8589-11D1-B16A-00C0F0283628' id='ProgressBar1'
height='20' width='400'>"
strProgress = strProgress & "<param name='Min' value='0'>"
strProgress = strProgress & "<param name='Max' value='" & lngRowCount &
"'>"
strProgress = strProgress & "<param name='Orientation' value='0'>"
strProgress = strProgress & "<param name='Scrolling' value='1'>"
strProgress = strProgress & "</object>"
document.getElementById("progress").innerHTML = strProgress
Sleep(1)
For Each rtnMatch In objMatch
strContract = rtnMatch.Value
document.getElementById("contract").innerHTML = "<span>Parsing
Contract: " & strContract & "</span>"
If ProgressBar1.Value < ProgressBar1.Max Then ProgressBar1.Value =
ProgressBar1.Value + 1
document.execCommand("Refresh")
lngStart = rtnMatch.FirstIndex
lngFinish1 = InStr(lngStart, strACHText, vbCrLf)
lngFinish2 = InStr(lngFinish1 + 2, strACHText, vbCrLf) - (lngFinish1 +
2)
strLine1 = Mid(strACHText, lngStart, lngFinish1 - lngStart)
strLine2 = Mid(strACHText, lngFinish1 + 2, lngFinish2)
strTemp = strTemp & Trim(strLine1) & " " & Trim(strLine2) & vbCrLf
Next
strACHFile = Mid(strFolderFile, InStrRev(strFolderFile, "\") + 1)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strRoot & Left(strACHFile,
Len(strACHFile) - 3) & "tmp", forWriting, createFile)
objFile.Write strTemp
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Call createExcel()
End If
Set objMatch = Nothing
Set objRegExp = Nothing
End Sub
"mr_unreliable" <kindlyReply...@notmail.com> wrote in message
news:OtspsLtq...@TK2MSFTNGP04.phx.gbl...
Why do you say it will add one second per line. It can be set to an
interval large enough to let the display update, but small enough to
minimize its impact.
In addition, you don't have to update the screen after every iteration
through the loop. Set it to happen every 100th time, instead.
Finally, as much as I admire mr unreliable's work, in general, I think
he's wrong about the Refresh. The issue is that your underlying
process is hogging all of the time available, such that the Refresh
can't take effect. Beside that, I think that a refresh should result
in the HTA returning to it's initialized state, that is like it was
just reloaded, not to the state at the time of the refresh. At least,
that's what would happen if you were to press the refresh key (F5) or
select the Refresh menu item in a browser window.
Thank you for following up - I'm going to implement your idea - I may be
able to get away with little to no impact... Thanks!
"Tom Lavedas" <tglb...@cox.net> wrote in message
news:f7e88ed3-15db-48c4...@a23g2000hsc.googlegroups.com...
--
Joe Fawcett (MVP - XML)
A method I use is to show a small clock icon
and change the cursor while working. It's a bit
clunky, but it serves to inform people of what's
happening and stop them from trying to click
buttons. (After all, no one can do anything
while your function is running anyway, so keeping
the painting refreshed isn't of much value.)
The way this method works is that I put the clock
picture in a table with an ID set to not display:
TABLE.clock {display: none;}
Then I can toggle the display from code.
When I want to show the clock I use:
document.body.style.cursor = "wait"
ShowClock
The ShowClock sub just handles the CSS code to
make the clock visible center-screen, with a high
z-index to put it on top of everything else. Then I
also call a hack version of DoEvents, which is needed
for IE to paint the clock before starting the long
operation that's going to freeze it:
Sub DoEvents()
SH.run "%comspec% /c exit", 0, True
End Sub
(SH is WScript.Shell.)
When the operation is done the HideClock sub just
changes the style display property of the table, to
hide the clock, and returns the cursor to normal.
I don't remember whether I tested this method
successfully on all systems.
http://www.google.com/search?complete=1&hl=en&q=document.execCommand+vbscript&aq=f
My response was more to the fact that: document.execCommand("Refresh") did
not work in the context I was using it, and maybe mr_unreliable had a fix :)
"Joe Fawcett" <joefa...@newsgroup.nospam> wrote in message
news:epdnlQ3q...@TK2MSFTNGP06.phx.gbl...
"mayayana" <mayaXX...@mindXXspring.com> wrote in message
news:%23hrxxw4...@TK2MSFTNGP05.phx.gbl...
Strictly speaking it is not Java (JScript), but rather a part of the
browser's document object model (DOM) which is language independent.
That is it can be used in JScript or VBS, if the browser supports
those - only IE does both, AFAIK. Plus, I believe IE's DOM is the
only one that supplies the execCommand() method but it's still not
Java. Your observation is probably an artifact of the fact that most
posts are from people using the more universal JScript to better
support a wider set of browsers.
"Tom Lavedas" <tglb...@cox.net> wrote in message
news:ab7b57a1-1628-4f42...@f63g2000hsf.googlegroups.com...
Woops. I didn't notice that part of your initial post.
hi JHP,
Many, if not most, professional scripters will advise you to
use IE (or an HTA) for a graphical user interface (gui), in
situations where a vbs msgbox or askbox is not good enough.
That is because IE (or an HTA) is Microsoft code which is
guaranteed to be 100 percent reliable and trustworthy. No
professional in his/her right mind would use anything but
Microsoft code.
However, there are a few scripters out there, who may indulge
in risky behavior and deviate from the microsoft "security
blanket". For those courageous and/or foolhardy folks, there
are other possibilities, and by using those other possibilities
you may avoid some of the shortcomings of IE (and/or HTA), like
the lack of "repaint" or even "doEvents".
For one, you could use a third-party control with vbs, which
will offer you an (almost) full gui capability (equivalent to
vb, because these 3rd-party controls are frequently written
in vb). Here are two that I have used successfully:
kixForms: http://www.kixforms.org/assets/index.htm
(written by: Shawn Tassie of CGI Canada)
wshDialog: http://home.hccnet.nl/p.vd.klugt/,
(written by: Peter J.C. van der Klugt)
For another, you could use a scripting language, (or a programming
language which is relatively uncomplicated so that is may almost
be regarded as a scripting language). There are a number of
languages which meet that criteria. All of these languages have
a more-or-less complete gui capability, and most have a COM
capability, although in some cases not as fully-developed as vbs.
FBSL: http://www.fbsl.net/phpbb2/index.php
o'Basic http://obasic.com/
Emergence BASIC: http://www.ionicwind.com/
FreeBASIC: http://www.freebasic.net/
In situations like this, I used to also recommend:
AutoIt3: http://www.autoitscript.com/autoit3/
but since autoit has dropped support of win98 (my os of choice),
I have dropped them.
There is also the "free" microsoft visual basic express edition,
which is an almost-full vb compiler. However, this is a vast step
into a much higher level of complexity, compared with vbs, and is
not recommended unless you wish to set aside a considerable amount
of time to learn it (or re-learn if you know vbClassic).
Thanks very much mr_unreliable and Joe Fawcett... fantastic - This is not a
Microsoft World (almost but not quite)
I was listening to Live - The Beauty Of Gray while writing this... you guys
have a good one!
"mr_unreliable" <kindlyReply...@notmail.com> wrote in message
news:ubflgyGr...@TK2MSFTNGP02.phx.gbl...
This is new. Most newsgroupies don't bother to update us
on their music of choice while posting techie stuff.
For the curious, here is T.B.O.G. in video:
http://www.youtube.com/watch?v=p5WIexiYeQg
cheers, jw