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!

multiple stmts in if else loop

Status
Not open for further replies.

KhushiRaina

Programmer
Oct 9, 2002
32
IN
Hi ALL,
I need to execute more than one stmt in the if else loop
For Eg:-

numberVar cnt1;
stringVar emps;

if cnt1 < 3 then
emps:=emps + {EMPLOYEE.FIRSTNAME} + &quot;,&quot;;
cnt1 := cnt1 + 1 ;
else
emps:=emps + {EMPLOYEE.FIRSTNAME} ;
With this formula i get error 'remaining text does not appear to be part of formula'
How to incorporate multiple stms in if-else loop.Pls any help is most welcome...looking forward for some solution..

Regds,
Khushi
 
The ';' terminates the IF statement.

Change the word 'else' to 'If cnt1 > 3 Then'

Naith

 
You need to use parentheses

numberVar cnt1;
stringVar emps;

if cnt1 < 3 then
(
cnt1 := cnt1 + 1 ;
emps:=emps + {EMPLOYEE.FIRSTNAME} + &quot;,&quot;;
)
else
emps:=emps + {EMPLOYEE.FIRSTNAME} ;

you will note that I also changed the order of the statements. Crystal likes the result of each if-then-else block to be of the same data type...and that is determined by the last operation in a block...so in this case they should both be strings.


Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top