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

nested IFs 1

Status
Not open for further replies.

slim2

Programmer
Oct 18, 2001
94
Is it possible to do nested Ifs in Crystal or If Endif
e.g.

If x = y Then
......
If a = b Then
.....;

I also saw If EndIf in the online help but it does not work it will not recognize ENDIF or END IF. I was trying

If a = b Then
statement
statement
statement
If x = y Then
statement
EndIf
EndIf


 
To the best of my knowledge, EndIf does not exist in crystal syntax, just keep doing
if-then-else statements:

If <<condition1>> then <<statement1>> else
If <<condition2>> then <<statement2>> else
....

you get the idea I am sure.

Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
Thanks for the response.

Yes, I see what you are saying, however the second condition i want to execute is dependent on the first.

If cond1 then statement1 statement2
also and only if the firt IF was true do the next
if cond2 then statement1 ....

I know I can repeat the first IF with an AND but I was wanting to reduce the amount of code and make it simpler.
 
In Crystal Syntax the semi-colon &quot;;&quot; is the equivalent to a basic &quot;End If&quot;

For nested IF's I use brackets to help me visually and reduce confusion

your example :

If a = b Then
statement
statement
statement
If x = y Then
statement
EndIf
EndIf

should be written

If a = b Then
(
statement;
statement;
statement;
If x = y Then
statement;
);
 
Thanks all for the help!!! it is appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top