Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link Functions: Replace function 2004-06-04 -- Jonathan Kay Newsgroups: comp.lang.clarion
> I need a procedure something like this
> ReplaceString(BigTextString,FindString,ReplaceString), where it looks for
> the FindString and replaces it with ReplaceString in the BigTextString.
I'd be inclined to do away with the 'BigString'; there may be times you
don't know how big to make it. Here's what I use - just prototype to return
a STRING:
Replace PROCEDURE(STRING Text,STRING Find,STRING Replace,BYTE CS=FALSE)
Pos UNSIGNED,AUTO
RVal ANY ! Do not add ,AUTO
CODE
LOOP
Pos =
CHOOSE(~CS,INSTRING(UPPER(Find),UPPER(Text),1),INSTRING(Find,Text,1))
RVal = RVal & CHOOSE(~Pos,Text,Text[1 : Pos-1] & Replace)
Text = CHOOSE(~Pos,'',Text[Pos+LEN(Find) : LEN(Text)])
UNTIL ~Text
RETURN RVal
Jon.
Today is November 21, 2024, 7:23 am This article has been viewed 35387 times. Google search has resulted in 12 hits on this article since January 25, 2004.
|
|