END terminator
Purpose: END immediately terminates a running program. END can be used in multiple places in your program.
Syntax: END [= ErrorLevel AS INTEGER] Parameters:
|
For example, this program, GetKey.bas, returns the key pressed as an errorlevel
DIM ErrorLevel% DO ErrorLevel% = INKEY LOOP WHILE ErrorLevel% = 0 END = ErrorLevel%
In the batch file example below GetKey is used to get a response based on an errorlevel from the hypothetical MyProg program.
:BEGIN MyProg.exe IF errorlevel = 0 GOTO done IF errorlevel = 1 GOTO noinit IF errorlevel = 2 GOTO baddata ECHO unknown error GOTO done :baddata ECHO Data was corrupt! Would you like to use Backup Data? Y/N GetKey.exe IF errorlevel = 89 GOTO olddata IF errorlevel = 121 GOTO olddata IF errorlevel = 78 GOTO done IF errorlevel = 110 GOTO done GOTO baddata :olddata COPY backup\MyProg.dat MyProg.dat GOTO BEGIN :noinit ECHO No Initialization File! Would you like to use Backup File? Y/N GetKey.exe IF errorlevel = 89 GOTO reinit IF errorlevel = 121 GOTO reinit IF errorlevel = 78 GOTO done IF errorlevel = 110 GOTO done GOTO noinit :reinit COPY backup\MyProg.ini MyProg.ini GOTO BEGIN :done
END PROGRAM terminator
Syntax: END PROGRAM |
Purpose: Intended for console mode programs, END PROGRAM forces the end of the main() function.
Remarks:
This is particularly handy when you want to include blocks of "C"
code outside of the main function.
☞ END PROGRAM must be used only once in your program.
An Example:
' Shows how BCX can use "C" functions directly $HEADER CHAR * Remove_All_White_Space(CHAR *); $HEADER DIM a$ DIM b$ a$ = " this is a test " b$ = Remove_All_White_Space(a$) PRINT b$ END PROGRAM ! CHAR* Remove_All_White_Space(CHAR* str1) ! { ! CHAR *obuf,*nbuf; ! if (str1) ! { ! for (obuf=str1,nbuf=str1;*obuf;++obuf) ! { ! if (!isspace(*obuf)) ! *nbuf++=*obuf; ! } ! *nbuf=0; ! } ! return str1; ! }