Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 26, 2016, 03:51:44 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: AleaPause  (Read 3062 times)

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
AleaPause
« on: January 06, 2014, 06:16:55 PM »

The idea is simple.

Delay the execution of a loop or Do While with an aleatory time in a range.
So I think i need an ini file to control the minimum time and the maximum time.
By example.
I have to do the next task in the range (1/2 hour to 1 hour)
In the ini file : 30, 60 minutes or any other accorded configuration.
The script don't liberate or allows the next step in my script until the time is passed.
I will insert the AleaPause script in my script to control aleatory times in a predefined range of time.
When the first task is done, enter AleaPause, then when finished the second task and so on while the loop ... do while .... enddo is acting.


Is this possible ?
 :-*

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,396
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #1 on: January 06, 2014, 06:55:36 PM »
Sleep.cmd

Hardcoded:
Code: Text [Select]
  1. REM Generate random number between 30 and 60
  2. set /a num=%RANDOM% * (%%60 - %%30 + 1) / 32768 + %%30
  3.  
  4. REM Multiply by 60 for minutes
  5. set /a delay = %num% * 60
  6.  
  7. REM Wait (timeout is a Win 7+ command)
  8. timeout %delay%


The non hardcoded version:
Code: Text [Select]
  1. REM Generate random number between first and second argument
  2. REM Second argument > first argument
  3. set /a num=%RANDOM% * (%2 - %1 + 1) / 32768 + %1
  4.  
  5. REM Multiply by 60 for minutes
  6. set /a delay = %num% * 60
  7.  
  8. REM Wait (timeout is a Win 7+ command)
  9. timeout %delay%

Sleep.cmd 30 60
« Last Edit: January 06, 2014, 08:22:36 PM by 4wd »

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #2 on: January 06, 2014, 07:57:10 PM »
Sleep.cmd

Hardcoded:
Code: Text [Select]
  1. REM Generate random number between 30 and 60
  2. set /a num=%random% %%60 +30
  3.  
  4. REM Multiply by 60 for minutes
  5. set /a delay = %num% * 60
  6.  
  7. REM Wait (timeout is a Win 7+ command)
  8. timeout %delay%


The non hardcoded version:
Code: Text [Select]
  1. REM Generate random number between first and second argument
  2. REM Second argument > first argument
  3. set /a num=%random% %%%2 +%1
  4.  
  5. REM Multiply by 60 for minutes
  6. set /a delay = %num% * 60
  7.  
  8. REM Wait (timeout is a Win 7+ command)
  9. timeout %delay%

Sleep.cmd 30 60


but where is the ini file ?
 :-[

I can understand almost in the batch language. I'll try executing. It's the best.

Best Regards
 :-*

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #3 on: January 06, 2014, 08:07:39 PM »
One consideration.
I will run this script in a virtual machine under windows xp pro
And perhaps under windows 7 someday.
The hard code option offer the console with the counting. I would like something more interactive.
I have to edit the cmd file to vary the arguments.
 :P

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #4 on: January 06, 2014, 08:10:01 PM »
something fails.
Begin with 4860 seconds. More than 1 hour.
The target was between 1/2 hour and 1 hour.
 :-[

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,396
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #5 on: January 06, 2014, 08:23:04 PM »
Begin with 4860 seconds. More than 1 hour.
The target was between 1/2 hour and 1 hour.

Fixed.

For XP:
Code: Text [Select]
  1. REM For XP
  2. @echo off
  3.  
  4. REM Generate random number between first and second argument
  5. REM Second argument > first argument
  6. set /a num=%RANDOM% * (%2 - %1 + 1) / 32768 + %1
  7.  
  8. REM Multiply by 60 for minutes
  9. set /a delay = %num% * 60
  10.  
  11. REM Ping an invalid IP once per second
  12. for /l %%a in (1,1,%delay%) do (ping 1.1.1.1 -n 1 -w 1000 > nul)
« Last Edit: January 06, 2014, 08:32:14 PM by 4wd »

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #6 on: January 06, 2014, 08:29:07 PM »
The final script will be compiled.
So I can't vary easily sleep.cmd 30 60
 :tellme:

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #7 on: January 06, 2014, 08:31:56 PM »
Begin with 4860 seconds. More than 1 hour.
The target was between 1/2 hour and 1 hour.

Fixed.

Why the hard coded version don't remail the console window ?
I see nothing
 :(

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,396
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #8 on: January 06, 2014, 08:38:05 PM »
The final script will be compiled.

So just add the relevant script commands in your program to cause a delay in whatever script language you're using ... since you haven't told us.

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #9 on: January 06, 2014, 08:39:41 PM »
xp version fails too.
Invalid IP why ?
 :-*

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #10 on: January 06, 2014, 08:40:37 PM »
The final script will be compiled.

So just add the relevant script commands in your program to cause a delay in whatever script language you're using ... since you haven't told us.

Will be dBASE
 :P

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,396
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #11 on: January 07, 2014, 01:58:39 AM »
xp version fails too.
Invalid IP why ?

Um, because it's supposed to?

Works OK on my XP machine and you'll never see the result of the ping unless you've modified the ping command (> nul) or your systems redirection is borked.

Code: Text [Select]
  1. REM For XP
  2. @echo off
  3.  
  4. REM Generate random number between first and second argument
  5. REM Second argument > first argument
  6. set /a num=%RANDOM% * (%2 - %1 + 1) / 32768 + %1
  7.  
  8. REM Multiply by 60 for minutes
  9. set /a delay = %num% * 60
  10.  
  11. REM Ping an invalid IP once per second        <---------------------------------------------------------------
  12. for /l %%a in (1,1,%delay%) do (ping 1.1.1.1 -n 1 -w 1000 > nul)

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #12 on: January 07, 2014, 11:18:14 AM »
xp version fails too.
Invalid IP why ?

Um, because it's supposed to?

Works OK on my XP machine and you'll never see the result of the ping unless you've modified the ping command (> nul) or your systems redirection is borked.

Code: Text [Select]
  1. REM For XP
  2. @echo off
  3.  
  4. REM Generate random number between first and second argument
  5. REM Second argument > first argument
  6. set /a num=%RANDOM% * (%2 - %1 + 1) / 32768 + %1
  7.  
  8. REM Multiply by 60 for minutes
  9. set /a delay = %num% * 60
  10.  
  11. REM Ping an invalid IP once per second        <---------------------------------------------------------------
  12. for /l %%a in (1,1,%delay%) do (ping 1.1.1.1 -n 1 -w 1000 > nul)


Trying. I don't understand everything , but I will try
 :P

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: AleaPause
« Reply #13 on: January 07, 2014, 11:23:20 AM »
xp version fails too.
Invalid IP why ?

Um, because it's supposed to?

Works OK on my XP machine and you'll never see the result of the ping unless you've modified the ping command (> nul) or your systems redirection is borked.

Code: Text [Select]
  1. REM For XP
  2. @echo off
  3.  
  4. REM Generate random number between first and second argument
  5. REM Second argument > first argument
  6. set /a num=%RANDOM% * (%2 - %1 + 1) / 32768 + %1
  7.  
  8. REM Multiply by 60 for minutes
  9. set /a delay = %num% * 60
  10.  
  11. REM Ping an invalid IP once per second        <---------------------------------------------------------------
  12. for /l %%a in (1,1,%delay%) do (ping 1.1.1.1 -n 1 -w 1000 > nul)


Trying. I don't understand everything , but I will try
 :P

In seven fails to me.
In xp under virtual machine fails to me.
I don't know what i am doing bad.
First time open a console window. Now never in seven.

What can i do to depure this ?

Best Regards
 :-*