` Replace function (Jonathan Kay) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

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 April 18, 2024, 9:22 pm
This article has been viewed 35111 times.
Google search has resulted in 12 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: