Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


UDF StrReplace Ignore Case

Keywords: 	 UDF StrReplace Ignore Case

#DefineFunction StrReplaceNC(DaString,old,new)
len=strlen(DaString)
oldlen=strlen(old)
newlen=strlen(new)
bbsize=len
if newlen > oldlen then bbsize=bbsize+( (len/old) * new))
bbsize=bbsize+10000 ; for good luck
bb=BinaryAlloc(bbsize)
BinaryPokeStr(bb,0,DaString)
BinaryReplace(bb,Old,new,@FALSE)
ans=BinaryPeekStr(bb,0,BinaryEODGet(bb))
BinaryFree(bb)
return (ans)
#EndFunction

input=" Hello Cat the dog said to the cAt"
oldx="cat"
newx="Sam"
output=StrReplaceNC(input,oldx,newx)
Message(input,output)


Article ID:   W15321