How to search for a string in a file – Gasboy CFN III Mgnr's Mnl V3.4 User Manual
Page 218

Advanced Command Files
Page 202
MDE-4315 CFN Series CFN III Manager’s Manual for Windows NT · August 2004
Here is an example of a skeleton for a more complex program that uses subroutines.
How to Search for a String in a File
Use the disk-based program FIND to find and print all occurrences of a specified string in one
or more files. The format of FIND is:
FIND[;[A][I]] pattern file1 [file2] . . .
FIND prints all lines that include one or more occurrences of the specified pattern. If pattern
contains spaces, it must be enclosed in double quote marks (“). With A option, FIND prints the
name of the file and the line number of each occurrence of the pattern.
FIND maintains a counter with how many times the pattern was found. The value of this
counter (up to 9999) is returned as the error code from FIND. The %E variable contains the
error code from the last command executed. If a line has more than one occurrence of the
pattern on it, the line will be printed only once, but the counter will reflect the correct number
of total occurrences. With the I option, the counter will give the total number of lines the
pattern was found on, rather than the total number of occurrences of the pattern.
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 ==================
P* TYPE TEST5.CMD
↵
* test for number of island
card readers down
PRINT DIAG;>SCRATCH 3
FIND;>NULL “went down”
SCRATCH
ECHO Island readers down =
%E
DEL SCRATCH
P*