home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFPRC1
/
MAKEB.SRF
< prev
next >
Wrap
Text File
|
1996-04-28
|
1KB
|
37 lines
/* ----------------------------------------------------------------------- */
/* MAKE BLOCK: Replace all occurences of NEEDLE in HAYSTACK
. with delim1 needle delim2.
. If delim1 and delim2 not give, then { AND } are used.
. Example: make_block(boys,' there are wild boys out there','<b>',' </b>')
. returns 'there are wild <b>boys </b> out there'
. (note that spaces are all retained)
*/
/* ----------------------------------------------------------------------- */
sref_make_block:
parse arg needle, haystack, delim1 , delim2, check_case
if delim1="" then delim1='{'
if delim2="" then delim1='}'
build=""
do forever
if check_case<>1 then
mm=pos(translate(needle),translate(haystack))
else
mm=pos(needle,haystack)
if mm=0 then do
build=build||haystack
return build
end
t1=substr(haystack,1,mm-1)
t2=substr(haystack,mm,length(needle))
haystack=substr(haystack,mm+length(needle))
build=build||t1||delim1||t2||delim2
end