I am using Crystal 8.5 and Crystal Syntax for formulas. I declare the following variables:
Local numberVar intIndex;
Local stringVar strResult := "";
Local stringVar strSymbol := "";
The following syntax generates no errors:
if {?DataType} = "N" or {?DataType} = "S" then
if {?Result}[intIndex] in ".0123456789" then
strResult := strResult & {?Result}[intIndex]
else
strSymbol := {?Result}[intIndex]
else
strResult := ""
Whereas the following syntax generates the error "A boolean is required here.", and places the cursor just before the "str" of "strResult" in the "else" clause:
if {?DataType} = "N" or {?DataType} = "S" then
for intIndex := 1 to Length({?Result}) step 1 do
if {?Result}[intIndex] in ".0123456789" then
strResult := strResult & {?Result}[intIndex]
else
strSymbol := {?Result}[intIndex]
else
strResult := ""
And the following syntax generates the error "A string is required here.", and places the cursor just before the "f" of "for":
if {?DataType} = "N" or {?DataType} = "S" then
strResult := ""
else
for intIndex := 1 to Length({?Result}) step 1 do
if {?Result}[intIndex] in ".0123456789" then
strResult := strResult & {?Result}[intIndex]
else
strSymbol := {?Result}[intIndex]
It looks as though you cannot have a "for" loop nested inside an "if" statment.
Is there a mistake in my syntax, or do Crystal 8.5 formulas not allow "for" loops to be nested inside "if" statements?
Thank you.
Local numberVar intIndex;
Local stringVar strResult := "";
Local stringVar strSymbol := "";
The following syntax generates no errors:
if {?DataType} = "N" or {?DataType} = "S" then
if {?Result}[intIndex] in ".0123456789" then
strResult := strResult & {?Result}[intIndex]
else
strSymbol := {?Result}[intIndex]
else
strResult := ""
Whereas the following syntax generates the error "A boolean is required here.", and places the cursor just before the "str" of "strResult" in the "else" clause:
if {?DataType} = "N" or {?DataType} = "S" then
for intIndex := 1 to Length({?Result}) step 1 do
if {?Result}[intIndex] in ".0123456789" then
strResult := strResult & {?Result}[intIndex]
else
strSymbol := {?Result}[intIndex]
else
strResult := ""
And the following syntax generates the error "A string is required here.", and places the cursor just before the "f" of "for":
if {?DataType} = "N" or {?DataType} = "S" then
strResult := ""
else
for intIndex := 1 to Length({?Result}) step 1 do
if {?Result}[intIndex] in ".0123456789" then
strResult := strResult & {?Result}[intIndex]
else
strSymbol := {?Result}[intIndex]
It looks as though you cannot have a "for" loop nested inside an "if" statment.
Is there a mistake in my syntax, or do Crystal 8.5 formulas not allow "for" loops to be nested inside "if" statements?
Thank you.