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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search for character in a field

Status
Not open for further replies.

sjlsysprg

Programmer
Oct 12, 2001
9
US
is there something in crystal that well allow me to find character in a fields like Charindex in SQL. It needs to be able to go thru the whole field and chars must start in a old number location.


Thanks
Suzy
 
If there is only one occasion of the character(s) you can use;
if remainder (instr({@abc},{?look up}),2)=1
then do this
else do something else

If there are multiple occasions of the string, the following loop will check each occurance of the string. The loop will search for any size string. (within the Crystal limits of course). The loop will also indicate whether the searched for string is present in the original.

change the following fields:
{abc} to the string you are evaluating,
{look up} to the field or string you want to check for,


stringvar check:={abc};
numbervar loop;
stringvar what:={look up};
numbervar lngth:=length(what);
stringvar a;

if instr(check,what)<> 0 then (
for loop:= 1 to length(check) do(
if instr(check[loop to length(check)],what)<>0 then
(if (check [loop to loop + lngth-1] = what and
remainder(loop,2)=1) then
(a:=&quot;okay&quot; ;loop:=loop+lngth+1) else
if (check [loop to loop + lngth-1] = what and
remainder(loop,2)=0) then
(a:=&quot;error&quot; ; loop:=length(check)))
else (loop:=length(check)));a)
else &quot;string not found&quot;

Mike

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top