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

Split text fields in v7

Status
Not open for further replies.

zootweller

Technical User
Oct 7, 2001
46
GB
Hi

I have a string field (called 'Transaction') where several components exist, seperated by full-stops, eg:

"ContractName.Location.Code.Type.System"

Sometimes the string can contain an extra ccomponent, so
I would like to tell Crystal that if there are 5 full-stops in the string, return the text after it.

I have tried variations of mid({Transaction}, instr({Transaction},".")+1) but v7 is weak without instrrev or the ability to use looping.

Any help (other than upgrading!) would be appreciated.
 
Hi !

Here is something that you can try.

I think it will give you the text after the 5 full-stops

NumberVar Pos1;
NumberVar Pos2;
NumberVar Pos3;
NumberVar Pos4;
NumberVar Pos5;
NumberVar Pos6;

if instr({Transaction},'.') > 0 then
Pos1 := instr({Transaction},'.');

if instr(mid({Transaction},Pos1+1),'.') > 0 then
Pos2 := Pos1 + instr(mid({Transaction},Pos1+1),'.');

if instr(mid({Transaction},Pos2+1),'.') > 0 then
Pos3 := Pos2 + instr(mid({Transaction},Pos2+1),'.');

if instr(mid({Transaction},Pos3+1),'.') > 0 then
Pos4 := Pos3 + instr(mid({Transaction},Pos3+1),'.');

if instr(mid({Transaction},Pos4+1),'.') <> 0 then
Pos5 := Pos4 + instr(mid({Transaction},Pos4+1),'.');

if Pos5 <> 0 then
mid({Transaction},Pos5+1)
else
'';

/Goran
 
Try this one:

WhilePrintingRecords;
StringVar Out := {Your.Field};
NumberVar End := Len ( Out) ;
NumberVar Start := 1;

Out:= Out [Start to end ];
Start:= Instr (Out, ".")+1;
Out:= Out [Start to end ];
Start:= Instr (Out, ".")+1;
Out:= Out [Start to end ];
Start:= Instr (Out, ".")+1;
Out:= Out [Start to end ];
Start:= Instr (Out, ".")+1;
Out:= Out [Start to end ];
Start:= Instr (Out, ".")+1;
Out:= Out [Start to end ];
Start:= Instr (Out, ".")+1;
Out:= Out [Start to end ];
Start:= Instr (Out, ".")+1;
Out:= Out [Start to end ];
Out

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top