home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFPRC1
/
EXTRACTB.SRF
< prev
next >
Wrap
Text File
|
1996-04-28
|
1KB
|
41 lines
/* ----------------------------------------------------------------------- */
/* EXTRACT_BLOCK
. extract a block from haystack, defined by a Labeled block,
. where the label has the form delim1 label delim2 multi-line_string delim3 xxx
. Default values of delim1={, 2=} 3={
. Note that labels must have NO embedded spaces.
*/
/* ----------------------------------------------------------------------- */
sref_extract_block:
parse arg haystack , alabel , delim1 , delim2 , delim3
if delim1='' then delim1='{'
if delim2='' then delim2='}'
if delim3='' then delim3=delim1
alabel=translate(alabel)
thaystack=translate(haystack)
/* see any alabel appears anywhere */
foo=pos(alabel,thaystack)
if foo=0 then return "" /* no match to label name, so no label */
/* might as well use this info, it's probably very good */
foo0=lastpos(delim1,haystack,foo) /* find potential beginning */
if foo0=0 then foo0=foo /* false lead, but we can start from here */
/* start the definitive search at this first guess */
maybe=substr(haystack,foo0)
do until maybe=""
parse var maybe e1 (delim1) labelq (delim2) maybe
labelq=strip(labelq)
if translate(labelq)=alabel then do
parse var maybe putem (delim3) .
return putem
end
end
return "" /* if here, no match */