from the scratch :
break on
dim $x
$file = @scriptdir + "\test.txt"
$search = "phrase to replace"
$replace = "phrase to insert"
$FileStr = ""
$ = open(1,$file,2)
if not @error
$x = readline(1)
while not @error
if instr($x,$search)
$FileStr = $FileStr + join(split($x,$search),$replace) + @crlf
else
$FileStr = $FileStr + $x + @crlf
endif
$x = readline(1)
loop
$ = close(1)
del $file
$ = open(1,$file,5)
$ = writeline(1,$FileStr)
$ = close(1)
? "File has been adapted" ?
else
? "file open failed : " + @serror ?
endif
? "Hit any key to quit ..."
get $
This replaces (if present) $Search by $replace
Possible problem : it adds an additional @crlf at the end
(Ok ... tested with my host file and it adds the additional crlf only if there is none in the original, speak, it adds only once !
Hehe : changed by this all entries called daimlerchrysler.com to chryslerdaimler.com and back
This scriplet has evil powers if used in a loop to modify remote files
)
hth
Jochen
[ 19. February 2003, 11:35: Message edited by: jpols ]
_________________________