This command file is used to list an area of a file starting with some search
string, and continuing on until the second search string. (Optional)
Usage: Ctext string1 [string2] [outfile]
This Qedit command file will find string1, then print lines until it finds string2. If string2 is omitted, then 3 lines will be printed.
Output can be redirected to outfile, which will be temp variable.
CTEXT.CMD
---------
parm instring1="?",instring2="",outfile="ctextout"
echo CText by /KenR Copyright 1997 Robelle Solutions Technology Inc.
comment
comment Copyright 1997 Robelle Solutions Technology Inc.
comment Written by Ken Robertson August 1997
comment ken@robelle.com
comment
if "!instring1"="?" then
echo Usage: Ctext string1 [string2] [outfile]
echo
echo Ctext will find string1 and print lines to string2.
echo If string2 is not specified, then the 3 lines after the first string
echo will be printed.
echo
echo If outfile is specified, then output will be re-directed to that file.
return
endif
comment save the current line in zz
/zz */* > $null
/v zz > zzsave
/lq first > $null
if "!outfile" <> "" then
echo File listing from !hpdatef > !outfile
endif
setvar find_count 0
setjcw cierror 0
setvar not_eof true
echo I/O Re-direction is kind of slow.
echo ...Working...hang on!
while not_eof do
continue
/findq "!instring1"
if cierror <> 0 then
setvar not_eof false
else
setvar find_count find_count + 1
if "!instring2"="" then
/list */*+3 >> !outfile
else
/zz */* > $null
continue
/findq "!instring2"
if cierror <> 0 then
/list * >> !outfile
else
/zz zz/* > $null
/list zz >> !outfile
endif
endif
endif
echo ----- >> !outfile
endwhile
/use zzsave
if find_count = 0 then
echo Sorry, !instring1 was NOT found in the file.
else
echo !find_count entries located in the file.
echo
if "!outfile =" <> "" then
print !outfile
endif
endif
....Back to the Qedit Q&A Page
|
|
|---|