Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: dumb question about syntax Post Reply Post New Topic
Author Message
NedSchneebly
Newbie
Newbie


Joined: 09 Jul 2009
Location: Canada
Online Status: Offline
Posts: 23
Quote NedSchneebly Replybullet Topic: dumb question about syntax
     Posted: 07 Aug 2009 at 1:25pm

Hi all - I am using CR XI.

I have no knowledge at all of Crystal Syntax, Crystal Basic or Visual Basic. I know some perl. My question is a very simple one, but I've been googling all day and can't seem to find an answer, or even some sample code that addresses my question.

I would like to know how Crystal Syntax handles a block of code?

For instance, in perl you can write:

if (x > y) {
  x = 0;
}
else {
  x = 1;
  z= 4;
}

Where *both* of the assignments ("x=1" and "z=4") are made if the "if" test is false.

I am trying to do the same in Crystal Syntax, but I just can't figure out how to put two statements into one block. When I do:

If (x > y) Then x := 0 Else x := 1; z := 4;

The code assigns 4 to z regardless of the tests, because it is not blocked in with the other "else" command.

I tried:

else x = 1, z = 4;
else (x = 1; z = 4);
else {x = 1; z = 4};

Needless to say, I am just using common sense and guessing (!). Can someone answer this very "basic" question for me? Thanks!

PS I have poured over dozens of formulas I found on the web, and not one of them ever used a "block of code" (maybe you just can't do it in CS and I am beating my head against a wall here).



Edited by NedSchneebly - 07 Aug 2009 at 1:30pm
Sigless and Bible Black
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Aug 2009 at 8:23am
else(
x:=1;
z:=4
);
 
:= is assignment, = is equality
() delimit a block of code.
;needed after each line--except the last one.
 
HTH
IP IP Logged
NedSchneebly
Newbie
Newbie


Joined: 09 Jul 2009
Location: Canada
Online Status: Offline
Posts: 23
Quote NedSchneebly Replybullet Posted: 10 Aug 2009 at 10:40am
> () delimit a block of code.

Hmm, I tried that but must have screwed up the syntax.
Thank you!
 


Edited by NedSchneebly - 10 Aug 2009 at 10:40am
Sigless and Bible Black
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum