home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource1
/
cenvid
/
batloops.bat
< prev
next >
Wrap
DOS Batch File
|
1993-03-19
|
2KB
|
90 lines
@echo off
REM CEnviX1.bat
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
cenvi 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
cenvi "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
cenvi "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,bat,: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,bat,: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 .BAT EXTENSION ON THE INPUT TELLS CENVI TO CALL main(argc,argv) WITH
ECHO THE COMMAND LINE ARGUMENTS
PAUSE
cenvi %0.bat 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=