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

Split String without a Delimiter

Status
Not open for further replies.

Awat

Technical User
Jun 2, 2010
14
US
Hi,
How can I split a string that doesn't contain a delimiter?
I need to extract 3 character codes that are strung together in 1 field without a delimiter. For example, I have a string that looks like this:
212356244120000000000000000 (40 char)
I need to split them into
212
356
244
120
and be able to search for a specific code i.e "244".
Thank you.
awat
 
not quite what i think you want/need, but maybe it will point you in the right direction.
You should at least be able to use it to tell if the 3 digits you want are anywhere in your field.

numbervar sp;
numbervar di;

for sp := 1 to len({table.field})-2 do(
IF MID({table.field},sp,3) = "224" then di := di + 1 else di := di
);
di


You could also try a totally different approach and create separate formulas for each 3 digit value:
//{@3first}
IF LEFT({table.field},3) = "224" then "MARKED" else ""

//{@3second}
IF MID({table.field},4,3) = "224" then "MARKED" else ""

//{@3third}
IF MID({table.field},7,3) = "224" then "MARKED" else ""

//{@3fourth}
IF MID({table.field},10,3) = "224" then "MARKED" else ""

etc.
 
hi, fisheromacse

How do I get the first approach to return something else other than an increment so that I will be able to extract the records with code 244 and suppress the ones without?

Thank you.
Awat
 
stringvar x := {table.string};
numbervar i;
numbervar j := 39; //not sure why there are 40 characters if they are supposed to be
//evaluated in threes
booleanvar y := false;
for i := 1 to j step 3 do(
if mid(x,i,3)='244' then
y := true
);
y

Then you would just use a detail suppression formula like this:

booleanvar y;
y = false //note no colon

-LB
 
Thank you, lbass! It's working!
fisheromacse, your 2nd approach works really well too. Thank you!

awat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top