Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop

Status
Not open for further replies.

Kim296

MIS
Aug 24, 2012
98
US
Can anyone tell me the right way to make the following loop through multiple search words. (Ex. Search1, Search2, Search3, etc.) Right now, it will only search the text using 1 search word.


Shared StringVar SearchText := {@SEARCH1} ;
StringVar Htm1 := "<font color=#FF0066>";
StringVar Htm2 := "<b>";
StringVar Htm5 := "</b>";
StringVar Htm6 := "</font>";
StringVar Result := "";
StringVar Temp := "";
NumberVar Start := 1;
NumberVar Ln := Len(SearchText);
NumberVar Loc := Instr({@NOTES}, SearchText);
While Loc > 0 Do (
Temp := Mid({@NOTES}, Start, Loc - Start) + Htm1 & Htm2 + Mid({@NOTES}, Loc, Ln) & Htm5 & Htm6;
Result := Result + Temp;
Start := Loc + Ln;
Loc := Instr(Start, {@NOTES}, SearchText);
);
Temp := Mid({@NOTES}, Start);
Result := Result + Temp;
Result
 
I would recommend looking at the REPLACE function as an alternate option to building a complex loop. I think the below would be close to what you want.

Code:
Shared StringVar SearchText := {@SEARCH1} ;
replace(replace(replace(replace(SearchText,"<font color=#FF0066>",""),"<b>",""),"</b>",""),"</font>","")

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top