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

Crystal syntax

Status
Not open for further replies.

newprogrammer999

Programmer
Aug 28, 2002
26
IE
Hi
I am just beginning to use crystal reports and I have a really simple question. I'm trying to print multiple lines from one if statement but I can't find the syntax to print multiple lines i.e.
If (condition)
then
"Hello world";
"Hello again"
else
""

does not work
can you help me
 
they don't have to go on seperate lines in the statement, but I like to put them on seperate lines for readability:

"Hello World"+chr(13)+
"Hello Again"

chr(13) and chr(10) are ASCII "carriage return" and "line feed"
 
If <<condition1>> then &quot;Hello World&quot; else
if <<condition2>> then &quot;Hello Again&quot; else &quot;&quot; Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
I have tried the first two solutions and the first solution is just printing &quot;Hello world&quot; and the second solution is not really applicable as there are quiet a number of conditions. Basically all I am trying to do is:
if condition
print some lines of text
else
if condition
print some lines of text
else
....

I don't mean top keep going on about this its just that the its such a simple problem that it is really buggin me:-(
 
Skuhlman's solution is doing what your example suggests, but your field is too small for you to see.

Right click your field, and toggle 'Can Grow' on.

If you're talking about nested ifs - like your second example - then it's:

If {WhoIsYourDaddy} = 'Puzzled'
Then 'Press F1 and check IF'
Else
If {WhoIsYourDaddy} = 'WorkedItOut'
Then 'Congratulations'
Else 'We got a problem' //this is the else for the 2nd IF
Else 'We still got a problem'; //this is the else for the main IF

Naith
 
The IF is as follows:

If {MyTable.MyField} = 'Say Hi&quot; then
'Hi'
Else
If {MyTable.MyField} = 'Say Bye&quot; then
'bye'
else
'nada'

Also consider the case statement:

select {MyTable.MyField}
case 'Say Hi' : 'Hi'
case 'Say Bye' : 'Bye'
default : 'Nada'

-k kai@informeddatadecisions.com
 
********************
If (condition)
then
&quot;Hello world&quot;;
&quot;Hello again&quot;
else
&quot;&quot;

********************

People have been giving you suggestions but not telling you the reason.

the way you have written the above formula. If the condition is positive then only &quot;Hello again&quot; would be printed (and even then I am not sure the formula will work because &quot;Hello world&quot; is not assigned).

Crystal does not print things as they are encountered in the formula. Only the last item is print. So &quot;Hello world&quot; would be overwritten in memory before it could be printed.

skuhlman gave you the correct form

If (condition)
then
&quot;Hello world&quot; + chr(13) + chr(10)+
&quot;Hello again&quot;
else
&quot;&quot; ;

This will print the second half on the second line (the chr(10) - linefeed seems to be optional but I always add it)

But is rereading your question I think you just gave a poor example for a different problem. How do you execute an &quot;IF block&quot; of statements

to do that you use parentheses

stringVar result1 := &quot;&quot;;
StringVar result2 := &quot;&quot;;

If (condition) then
(
result1 := &quot;Hello world&quot; + chr(13) + chr(10);
result2 := &quot;Hello again&quot;;
);

result1 + result2;


Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top