Save the 1st script as "SCRIPT.BAT"
Save the 2nd script as "LOOP.BAT"
Save the 3rd script as "LOOP2.BAT"
Put them all in the same directory
From the command line type "SCRIPT"
Everything else needed to know is
Located inside the "SCRIPT.BAT"
If there is a way to combine these
Methods any ideas would be appreciated.
The system I tested This Command On
Reported As So...
1000=1sec+2000=7sec
10000=10sec+20000=12sec
1000=7sec
10000=12sec
Ultimately all the echo commands can be
Replaced And Depending
On the number value those commands could
be launched as needed before the next block
of code executes in the main script
Code: Select all
@ECHO OFF
:: ASSIGNS THE VAR NAMED "VALUE" TO TWO DIFFERENT USER DEFINED VALUES
:: BASED ON TWO USER DEFINED TIME RELEASED SWITCHES THAT RUN INSIDE
:: THE LOOP THEN RETURNS THE VARIABLE NAMED "VALUE" BACK TO "0", ONLY
:: IF SETLOCAL IS ATTACHED TO THE HEADERS OF THE LOOP SCRIPTS
:: OTHERWISE THE VALUE RETURNS TO THE FIRST USER STATED VARIABLE.
:: CHANGING THE TIME RELEASE VALUE NUMBERS WHILE APPENDING THE
:: "/SYNC" SWITCH TO THE END OF THE COMMAND WILL SET THE "VALUE"
:: NAMES ACCORDING TO THEIR VALUE NUMBERS GENERALLY THE IDEA BEHIND THIS
:: COMMAND WOULD BE TO ASSIGN BOTH USER DEFINED VALUES TO THE "VALUE"
:: VARIABLE SIMOTANIOUSLY INSIDE THE EXTENDED LOOP. INHERENTLY IF THE NUMBER
:: VALUE FOR THE FIRST VAR "VarName001" IS LESS THAN "VarName002" THE NEXT
:: COMMAND IN THIS SCRIPT WILL EXECUTE BEFORE THE SECOND LOOP IS REACHED.
:: IF THE "/SYNC" SWITCH IS NOT PRESENT THE FIRST VARIABLE WILL BE SET
:: ACCORDING TO ITS NUMBERED VALUE THE SECOND VARIABLE WILL SET AND THEN
:: EXECUTE ONLY AFTER THE FIRST VAR HAS PASSED SUCCESSFULLY
REM BUGS:
REM WHEN THE "/SYNC" SWITCH IS PRESENT AND BOTH NUMBERED
REM VALUES ARE EQUAL THE VALUES ARE SET IN REVERSE
REM BEING "VarName002" THEN "VarName001"
REM WHEN IT SHOULD BE THE OTHER WAY AROUND WHEN
REM THE NUMBERED VALUES ARE EQUAL IT SHOULD READ
REM "VarName001" FIRST
:: PROBLEMS:
:: ANY VALUE BELOW "2" OUTPUTS AN ERROR
:: LARGER VALUES INCREASE CPU USAGE
:: SCRIPT~COMMAND ::
:: EXAMPLE ::
CALL LOOP VarName001 100 VarName002 9000 /SYNC
ECHO.
ECHO Commands That Would Be Launched While
ECHO "VarName002" Is Resolving Are Put Here
ECHO Once VarName002 Has Resolved And CMD
ECHO Exits, Both "VarName001" ^&^ "VarName002"
ECHO Will Both Equal The Variable "VALUE"
ECHO But Only From The Command Prompt
ECHO They Will Not Act As They Do In A Script
ECHO To Test This Theory Once "VarName002"
ECHO Has Resolved Type ECHO !VALUE! And
ECHO Hit Enter Then Type ECHO !VALUE! Again
ECHO And Hit Enter Both User Vars Will Now Equal
ECHO The Variable "VALUE" Make Sure To Enable
ECHO Delayed Expansion First Or Type VALUE
ECHO As Normal With %%%%% To Expand The Variable
Code: Select all
@ECHO OFF
TITLE RunLoop
:: The %Value% Variable Is The Variable
:: That We Will Assign Different Values To
IF /I "%5" == "/SYNC" (SET SYNC=1)
IF "%SYNC%" == "1" (SET SYNCCMD=%3) & (SET SYNCVAL=%4) & (START /B LOOP2) ELSE (GOTO :BEGIN*LOOP)
:BEGIN*LOOP
SET VAR01=1
:LOOP001
SET /A VAR01=%VAR01%+1
IF "%VAR01%" == "%2" (GOTO :END001)
GOTO :LOOP001
:END001
SET SplitVar=%1
SET Value=%SplitVar%
ECHO.
ECHO INSIDE OUR EXTENDED LOOP THE VARIABLE "VALUE"=%VALUE%
IF "%SYNC%" == "1" (GOTO :EOF)
SET VAR02=1
:LOOP002
SET /A VAR02=%VAR02%+1
IF "%VAR02%" == "%4" (GOTO :END002)
GOTO :LOOP002
:END002
SET SplitVar=%3
SET Value=%SplitVar%
ECHO.
ECHO INSIDE OUR EXTENDED LOOP THE VARIABLE "VALUE"=%VALUE%
Code: Select all
@ECHO OFF
TITLE RunLoop
ENDLOCAL
:BEGIN*LOOP
ECHO.
SET VAR02=1
:LOOP002
SET /A VAR02=%VAR02%+1
IF "%VAR02%" == "%SYNCVAL%" (GOTO :END002)
GOTO :LOOP002
:END002
SET SplitVar=%SYNCCMD%
SET Value=%SplitVar%
ECHO.
ECHO.
ECHO INSIDE OUR EXTENDED LOOP THE VARIABLE "VALUE"=%VALUE%