Gasboy CFN III Manager Manual V3.6 User Manual
Page 223
[P:]* TYPE TEST6.CMD
↵
* short example of GOTO usage
* first go to main program
goto MAIN
* ----- CHECKPERM subroutine ----
* CHECKPERM is a subroutine to check user’s permission level
* %P is current user’s permission level
*CHECKPERM:
if - %P 4
BEGIN
echo Permission denied; has level %P, needs level 4
exit
END
goto -Rb
* ---- main program starts here ----
*MAIN:
echo Main program starting
* check permission level
goto -Sb CHECKPERM
* program returns to here after doing CHECKPERM subroutine
echo Main program continuing
[P:]*
[P:]* TYPE TESTGOTO.CMD
↵
* uncomment this line for trace while debugging
* ================ TESTGOTO.CMD ===================
* Example of how to use goto for subroutines
*
* usage: TESTGOTO
*
* -------- jump to mainline ---------
goto MAIN
* ================ SUBROUTINES ====================
* ----- FIRST LEVEL A SUBROUTINES -----
* ------ your first subroutine -------
*SUBONE:
echo something
goto -Sb SUBSUB
echo something else
goto -Ra
* ------ your second subroutine -------
*SUBTWO:
echo do something new
goto -Sb SUBSUB
echo do something else new
goto -Ra
* ----- SECOND LEVEL B SUBROUTINES ----->
*SUBSUB:
echo do something again
goto -Rb
* ================= MAIN LINE =====================
*MAIN:
goto -Sa SUBONE
goto -Sa SUBTWO
* =============== END OF PROGRAM ==================
MDE-4871 CFN III Manager’s Manual for Windows® XP Embedded - Version 3.6 · August 2010
Page 20-11
How to Use the IF Command
Advanced Command Files
You can also use LOOP and RETURN. Here is an example of a subroutine you could use with
LOOP and RETURN.
Here is an example of a skeleton for a more complex program that uses subroutines.