Hello Crystal Masters!
(I am using Crystal 8.5)
I am in the process of using a while do loop to break down a list of comma separated codes, compare each code to a table that holds a description for that code and then put the descriptions into a commas separated list. The codes are various lengths but there are no spaces between and they are separated by commas. All the codes have corresponding descriptions.
Here is an example of databaseField: A23,Q1234,D241,V2
Here is an example of the table
A23 Apple 23
B2 Bee 2
C234 Cat 2
Q1234 Queen 1234
etc
This is what I have done so far:
Shared StringVar databaseField;
Shared NumberVar stringLen:= length(databaseField);
Shared StringVar list:= ' ';
Shared StringVar code:= {Gen_Tables.CODE};
Shared StringVar desc:= {Gen_Tables.DESCRIPTION};
Shared StringVar outString;
Local NumberVar a := 1;
Local NumberVar b := 1;
While a <= stringLen and
InStr(databaseField,","
> 0
Do
(
a:= Instr(a,noCommas2,","
-1;
Local stringVar c2:= databaseField[b to a];
If c2 = code then list2 := desc + ' a ' + totext(a) +
' b ' + totext(b);
a:= a + 1;
b:= a;
);
//these gather the commas separated descriptions into two
if length(list) > 3
then
outString:= outString + ', ' + list;
If I take out the While Do part then I can get the first code in the field to work but if I leave the While Do loop in then I get the "A loop was evaluated more than the maximum number of times allowed" error message.
I have been able to do this with single letter codes but not multiple.
Any help would be appreciated.
PCassada
(I am using Crystal 8.5)
I am in the process of using a while do loop to break down a list of comma separated codes, compare each code to a table that holds a description for that code and then put the descriptions into a commas separated list. The codes are various lengths but there are no spaces between and they are separated by commas. All the codes have corresponding descriptions.
Here is an example of databaseField: A23,Q1234,D241,V2
Here is an example of the table
A23 Apple 23
B2 Bee 2
C234 Cat 2
Q1234 Queen 1234
etc
This is what I have done so far:
Shared StringVar databaseField;
Shared NumberVar stringLen:= length(databaseField);
Shared StringVar list:= ' ';
Shared StringVar code:= {Gen_Tables.CODE};
Shared StringVar desc:= {Gen_Tables.DESCRIPTION};
Shared StringVar outString;
Local NumberVar a := 1;
Local NumberVar b := 1;
While a <= stringLen and
InStr(databaseField,","
Do
(
a:= Instr(a,noCommas2,","
Local stringVar c2:= databaseField[b to a];
If c2 = code then list2 := desc + ' a ' + totext(a) +
' b ' + totext(b);
a:= a + 1;
b:= a;
);
//these gather the commas separated descriptions into two
if length(list) > 3
then
outString:= outString + ', ' + list;
If I take out the While Do part then I can get the first code in the field to work but if I leave the While Do loop in then I get the "A loop was evaluated more than the maximum number of times allowed" error message.
I have been able to do this with single letter codes but not multiple.
Any help would be appreciated.
PCassada