Using scripts with function WScript.Sleep

Some time I need to incorporate a sleep space in my scripts.
For example

Sub WaitUntilFileIsReady(filePath)
Dim size1, size2
size1 = objFSO.GetFile(filePath).Size
Do
WScript.Sleep 500 ' Espera medio segundo
size2 = objFSO.GetFile(filePath).Size
If size1 = size2 Then Exit Do
size1 = size2
Loop
End Sub

But I get error in the execution. How can I solve this situation? Any suggestion?
Thanks

WScript isn't one of the provided objects when scripts run in Opus; that's only there for scripts running under WScript.

You can create some of the WScript objects, although I don't think it works for the main WScript object. Works for WScript.Shell:

var shell = new ActiveXObject('WScript.Shell');

For delays, the provided DOpus object has a similar method.

Thank you @leo.
Sorry for my inexperience. But How do I use de DOpus Delay function in my VBscript?

DOpus.Delay 500 would sleep for half a second.

1 Like

Again I have to load a script with a function WScript.Echo
I get that "WScript is not defined"
I suppose the problem is the same as with WScript.delay
My question is : How can I find the DOPUS equivalent for WScritp function? Is there a function search somewhere? What do you suggest for a dummy on this issue?
Thanks

You would need to run the script with wscript.exe in order to use the WScript object.

Sorry. Can you be more specific? with an example please.
Previously @leo make this comment

I thought that I should try to find DOpus objects instead of trying to unse WScript.
May be I didn't understand really what he wanted to tell me.
I am not fully english talking, neither strong programmer. Just advanced it user. Thanks.

Scripts run underneath a host. Hosts can provide objects to the script for it to use.

When you run a script within Opus, Opus is the host. Opus provides an object called DOpus (and another one called Script).

wscript is a program that comes with Windows that also lets you run scripts. When you run a script from wscript.exe, it provides an object called WScript.

You can't access the WScript object unless you run the script from wscript.exe, just like you can't access the DOpus object unless you run the script from Opus.

1 Like

DOpus.Output is probably what you want. Or the Dialog object if you want a message box.

Thank you for the clarifications @Jon @Leo .
and for the very fast answer :wink: