Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: "Pause" in code

  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi All,
    I am working with some VB script (5.5) on a piece of equipment and would like to pause, or delay, execution of the script for a couple of seconds. Does anyone know if this is possible? I am looking through the VB Script 5.5 help file and nothing sticks out to me.

    Thanks,
    Mark

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='santosm' post='783897' date='09-Jul-2009 18:49']I am working with some VB script (5.5) on a piece of equipment and would like to pause, or delay, execution of the script for a couple of seconds.[/quote]
    Not sure what you mean by "a piece of equipment," but if it runs the Windows Script Host, check out the WScript.Sleep Method. (This method is not part of native VBS.)

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    The equipment is a machine that acts like a printer with programmable input. There is an option to run VBScript 5.5 compliant commands with the job file when it runs. Looking at the VBS 5.5 help file I have, that Wscript method is not there, so I am not sure it will work. Any other ideas?

    Thanks,
    Mark

    [quote name='jscher2000' post='783905' date='09-Jul-2009 23:35']Not sure what you mean by "a piece of equipment," but if it runs the Windows Script Host, check out the WScript.Sleep Method. (This method is not part of native VBS.)[/quote]

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='santosm' post='783907' date='09-Jul-2009 20:52']The equipment is a machine that acts like a printer with programmable input. There is an option to run VBScript 5.5 compliant commands with the job file when it runs. Looking at the VBS 5.5 help file I have, that Wscript method is not there, so I am not sure it will work. Any other ideas?[/quote]
    Perhaps you can write a Do loop that simply burns up time doing something useless and monitoring the clock. However, if the goal is to let another process proceed in the background, you may need to find a method similar to Sleep (assuming the equipment is capable of multi-tasking different processes).

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I can use WScript.Sleep in a .vbs file without problems - see attached sample.
    Attached Files Attached Files

  6. #6
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Hans,
    I will try but I am not seeing that in the VBS 5.5 command reference.

    Thanks,
    Mark

    [quote name='HansV' post='783926' date='10-Jul-2009 03:58']I can use WScript.Sleep in a .vbs file without problems - see attached sample.[/quote]

  7. #7
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    WScript will not work with VBS 5.5. Do you have any ideas of another way to waste a second or two?

    Thanks,
    Mark

    [quote name='HansV' post='783926' date='10-Jul-2009 03:58']I can use WScript.Sleep in a .vbs file without problems - see attached sample.[/quote]

  8. #8
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That sounds like it may work. Any idea how you would monitor the clock?

    Thanks,
    Mark

    [quote name='jscher2000' post='783909' date='10-Jul-2009 00:02']Perhaps you can write a Do loop that simply burns up time doing something useless and monitoring the clock. However, if the goal is to let another process proceed in the background, you may need to find a method similar to Sleep (assuming the equipment is capable of multi-tasking different processes).[/quote]

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Does VBScript - sleep command help? (See the replies near the bottom of the thread)

  10. #10
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Hans,
    I can try this but "Sleep" is also not in the keyword list. I am now wondering if some sort of "Timer" DO/LOOP would work.


    Thanks,
    Mark

    [quote name='HansV' post='784035' date='10-Jul-2009 15:05']Does VBScript - sleep command help? (See the replies near the bottom of the thread)[/quote]

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I meant the Window.setTimeOut mentioned near the end - this will only work for web pages.

    I use VBScript very rarely, and then for very simple things only, so I can't offer much help.

  12. #12
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Hans,
    OK, no problem. I will keep trying things and if I come across something that works, I will post back.


    Take care,
    Mark


    [quote name='HansV' post='784047' date='10-Jul-2009 15:55']I meant the Window.setTimeOut mentioned near the end - this will only work for web pages.

    I use VBScript very rarely, and then for very simple things only, so I can't offer much help.[/quote]

  13. #13
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Have you tried something like this which was found here - http://www.experts-exchange.com/Web_Develo...Q_11973538.html
    dim startTimer, currentTimer
    dim duration 'in seconds
    duration=30

    startTimer=timer
    do while currentTimer<(startTimer+duration)
    currentTimer=timer
    Loop
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  14. #14
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Andrew,
    That looks good. I will give it a try.

    Thanks,
    Mark

    [quote name='Andrew Lockton' post='784100' date='10-Jul-2009 20:33']Have you tried something like this which was found here - http://www.experts-exchange.com/Web_Develo...Q_11973538.html
    dim startTimer, currentTimer
    dim duration 'in seconds
    duration=30

    startTimer=timer
    do while currentTimer<(startTimer+duration)
    currentTimer=timer
    Loop[/quote]

  15. #15
    2 Star Lounger
    Join Date
    May 2006
    Location
    Currently in Europe
    Posts
    103
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Just stumbled onto this thread while looking for something else. It's old, yet I may have an input of some use.

    A couple of years ago I faced the same problem and after stubborn searching on the net I found this (My apoligies to who and wherever this was posted - I can't remember):

    This item comes just before the macro itself, a bit like an 'option explicit'

    Private Declare Sub Sleep Lib "kernel32" (ByVal nMilliseconds As Long)

    In the code itself you can then write:

    Sleep 750

    Adjust the number to get as much delay as you need.

    I don't know how this works in Word 07. Also, the reference to 32 makes me think it's tied to the 32-bit OS. It is, then I don't know if this will work with a 64-bit OS.
    Stylus

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •