home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HomeWare 14
/
HOMEWARE14.bin
/
os2
/
cenv2_19.arj
/
BATLOOPS.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-03-08
|
3KB
|
95 lines
@echo off
REM *************************************************************************
REM *** BatLoops.cmd - Demonstrate various ways to enhance a batch file ***
REM *** ver.1 with looping using CEnvi. This also shows various ***
REM *** ways that CEnvi source code can be called from ***
REM *** within a batch file. ***
REM *************************************************************************
ECHO BatLoops: Use CEnvi and various methods to loop five times
ECHO
ECHO LOOP METHOD 1
ECHO THIS METHOD DEMONSTRATES THE CENVI CAPABILITY FOR MATHEMATICAL
ECHO PROCESSING OF VARIABLES, EVEN ENVIRONMENT VARIABLES
PAUSE
set LOOP_COUNT=1
:ABEGIN_LOOP
echo This is pass %LOOP_COUNT% through this loop - 1
call CEnviSet LOOP_COUNT++
if %LOOP_COUNT% == 6 GOTO AEND_LOOP
GOTO ABEGIN_LOOP
:AEND_LOOP
ECHO
ECHO LOOP METHOD 2
ECHO CENVI WILL SET AN ENVIRONMENT VARIABLE FOR THE PROPER GOTO LABEL
PAUSE
set LOOP_COUNT=1
:BBEGIN_LOOP
echo This is pass %LOOP_COUNT% through this loop - 2
call CEnviSet "LOOP_GOTO = ( LOOP_COUNT++ < 5 ) ? "BBEGIN_LOOP" : "BEND_LOOP""
GOTO %LOOP_GOTO%
:BEND_LOOP
ECHO
ECHO LOOP METHOD 3
ECHO CENVI SETS AN ENVIRONMENT VARIABLE TO A BATCH FILE STATEMENT
PAUSE
set LOOP_COUNT=1
:CBEGIN_LOOP
echo This is pass %LOOP_COUNT% through this loop - 3
call CEnviSet "LOOP_COMMAND = ( LOOP_COUNT++ < 5 ) ? "GOTO CBEGIN_LOOP" : " ""
%LOOP_COMMAND%
ECHO
ECHO LOOP METHOD 4
ECHO CENVI WILL EXECUTE CODE FROM SELECTED LINES OF THIS BATCH FILE
PAUSE
CEnvi #include "%0,cmd,:CODE4"
:CODE4 for ( i = 1; i <= 5; i++ )
:CODE4 printf(" This is pass %d through this loop - 4\n",i)
ECHO
ECHO LOOP METHOD 5
ECHO CENVI WILL READ SOURCE FROM THIS EXECUTABLE, AND THEN CALL A FUNCTION
PAUSE
CEnvi "#include <%0,cmd,:CODE5> LoopFoo(1,5)"
:CODE5 LoopFoo(min,max) {
:CODE5 for ( i = min; i <= max; i++ )
:CODE5 printf(" This is pass %d through this loop - 5\n",i)
:CODE5 }
ECHO
ECHO LOOP METHOD 6
ECHO THIS METHOD DEMONSTRATES THE USE OF A CMM "EXECUTABLE"; THAT IS, THE
ECHO .CMD EXTENSION ON THE INPUT TELLS CENVI TO CALL main(argc,argv) WITH
ECHO THE COMMAND LINE ARGUMENTS
PAUSE
CEnvi %0.cmd 1 5
GOTO CENVI_EXIT
main(argc,argv)
{
for ( i = atoi(argv[1]); i <= atoi(argv[2]); i++ )
printf(" This is pass %d through this loop - 6\n",i)
}
:CENVI_EXIT
ECHO
ECHO LOOP METHOD 7
ECHO CMM SOURCE CODE IS PASSED TO CENVI DIRECTLY ON THE COMMAND LINE
PAUSE
CEnvi "for ( i = 1; i <= 5; i++ ) printf(" This is pass %%d through this loop - 7\n",i)"
REM Cleanup up the variables used
set LOOP_COUNT=
set LOOP_GOTO=
set LOOP_COMMAND=
set METHOD_COUNT=