I'm using the following code in a formula variable (Crystal 11.0.0). On the first version, the error checker highlights the Else clause and says "A number is needed here." I broke the IF...THEN...ELSE into two IF statements and it works perfectly. I would appreciate any suggestions as to why this is necessary.
VERSION 1:
Local NumberVar tLen := length({?Test Method});
Local NumberVar start := 1;
Local NumberVar i := 1;
Local StringVar str := '';
//Loop through {GILEAD_TEST_METHODS.TEXT9} inserting HTML formatting around search string
While i>0 Do
(
i := instr(start,{GILEAD_TEST_METHODS.TEXT9},{?Test Method},1); //Case-insensitive search
If i > 0 Then (
str := str & mid({GILEAD_TEST_METHODS.TEXT9},start,i-start)&
'<b><font color="Red">' & Uppercase({?Test Method}) &'</font></b>';
start := i+tLen;
)
Else
str := str & mid({GILEAD_TEST_METHODS.TEXT9},start)
);
//Return the HTML-formatted string
str
VERSION 2:
Local NumberVar tLen := length({?Test Method});
Local NumberVar start := 1;
Local NumberVar i := 1;
Local StringVar str := '';
//Loop through {GILEAD_TEST_METHODS.TEXT9} inserting HTML formatting around search string
While i>0 Do
(
i := instr(start,{GILEAD_TEST_METHODS.TEXT9},{?Test Method},1); //Case-insensitive search
If i > 0 Then (
str := str & mid({GILEAD_TEST_METHODS.TEXT9},start,i-start)&
'<b><font color="Red">' & Uppercase({?Test Method}) &'</font></b>';
start := i+tLen;
//Else
If i = 0 Then
str := str & mid({GILEAD_TEST_METHODS.TEXT9},start);
);
//Return the HTML-formatted string
str
VERSION 1:
Local NumberVar tLen := length({?Test Method});
Local NumberVar start := 1;
Local NumberVar i := 1;
Local StringVar str := '';
//Loop through {GILEAD_TEST_METHODS.TEXT9} inserting HTML formatting around search string
While i>0 Do
(
i := instr(start,{GILEAD_TEST_METHODS.TEXT9},{?Test Method},1); //Case-insensitive search
If i > 0 Then (
str := str & mid({GILEAD_TEST_METHODS.TEXT9},start,i-start)&
'<b><font color="Red">' & Uppercase({?Test Method}) &'</font></b>';
start := i+tLen;
)
Else
str := str & mid({GILEAD_TEST_METHODS.TEXT9},start)
);
//Return the HTML-formatted string
str
VERSION 2:
Local NumberVar tLen := length({?Test Method});
Local NumberVar start := 1;
Local NumberVar i := 1;
Local StringVar str := '';
//Loop through {GILEAD_TEST_METHODS.TEXT9} inserting HTML formatting around search string
While i>0 Do
(
i := instr(start,{GILEAD_TEST_METHODS.TEXT9},{?Test Method},1); //Case-insensitive search
If i > 0 Then (
str := str & mid({GILEAD_TEST_METHODS.TEXT9},start,i-start)&
'<b><font color="Red">' & Uppercase({?Test Method}) &'</font></b>';
start := i+tLen;
//Else
If i = 0 Then
str := str & mid({GILEAD_TEST_METHODS.TEXT9},start);
);
//Return the HTML-formatted string
str