home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
ez-btm11.exe
/
EXT.BTM
< prev
next >
Wrap
Text File
|
1994-05-14
|
3KB
|
126 lines
:EXT.BTM
: Selects segments in file delimited by blank lines.
: (For example, an addresses file. See at the bottom of this file)
: If there is more than one occurrence of the word specified, a menu
: will pop up for selection.
: December 23, 1993
iff .%@search[ted.com]==. .and. .%@search[t.com]==. then
echo This program requires either TED or TERSE
echo (both available from simtel20 mirrors)
quit
endiff
if %@eval[%#] lt 2 .and. .%1==.example goto example
if %@eval[%#] lt 2 goto syntax
setlocal
set editor=ted
rem ^^^ change to 't' if your prefer TERSE
call settemp
set fn=%@unique[%temp]
set adfn=%1
set extfile=%temp%extract.itm
set items=%@eval[%#-1]
set items0=%items
:begin
set item=%2
find /i/n "%item" %adfn>>%fn
if .%editor==.t (keystack 0 alt-d alt-d alt-x^%editor %fn)
if .%editor==.ted (keystack 0 f8 f8 f7 enter^%editor %fn)
cls
iff %@lines[%fn] lt 0 .and. %items0 lt 2 then
set err=on
echo.^echo No %@upper["%item"] found in %@upper[%adfn]
endlocal
quit
elseiff %@lines[%fn] lt 0 .and. %items0 ge 2 then
echo --(%@upper["%item"] not found)-- >>%extfile
goto end
endiff
iff %@lines[%fn] gt 0 then
goto select_file
else
set sn=%@line[%fn,0]
goto analyse
endiff
:select_file
cls
set sn=%@select[%fn%,1,2,23,77, select desired item ]
if .%sn==.%@char[@27] (endlocal^quit)
:analyse
set border=%@eval[%@index[%sn,%@char[93]]-1]
set num=%@substr[%sn,1,%border]
if %@eval[%num] gt 0 set num=%@eval[%num-1]
:lines
set line=%@line[%adfn,%num]
if .%line==. goto end
set num=%@eval[%num+1]
echo %line >>%extfile
goto lines
:end
set items=%@eval[%items-1]
iff %items ge 1 then
echo --->>%extfile
del /q %fn
shift
goto begin
else
echo --->>%extfile
goto exit
endiff
:exit
del /q %fn
if .%editor==.t (del /q %temp%*.bak)
ex ca %extfile
endlocal
quit
=======
:syntax
echo.
echo Syntax is: %0 file_name search_item [search_item...]
echo.
echo (Type `%0 example' to see a sample)
quit
:example
cls
text
Here is an example of a text with segments delimited by blank lines:
JP Software
Order Department
P.O. Box 1470
East Arlington, MA 02174
U.S.A.
·tel +617-646-3975
·fax: +617-646-0904
·e-mail: 75300.210@CompuServe.COM
Dpto. de Filología española
Facultad de Filología
Universidad de Santiago de Compostela
15771 Santiago de Compostela
España
·tel: +34-81-575340
·fax: +34-81-574646
Svenska Akademiens Nobelbibliotek
Källargränd 4
S-111 29 Stockholm
Sweden
endtext
quit