Choosing a Formula Language: Crystal Versus Basic Syntax

In previous hours, the Crystal syntax was used for all formulas. However, formulas in Crystal Reports can be created, edited, and modified using one of two languages. The Crystal syntax is the most commonly used language, but the Basic syntax is also available.

Both languages are equal in their functionality meaning that if something was added to Crystal syntax, it was also added to Basic. The reason for having a choice is for the report designer's comfort a designer can use whichever language he is more comfortable with.

Syntax Differences

The Crystal syntax is most similar to the Pascal or Delphi programming languages. It's not exactly like Pascal, but if you're a Delphi developer or a longtime Crystal Report developer, this syntax is probably your first choice.

The Basic syntax is most similar to Visual Basic as a programming language. If you're a Visual Basic developer, you'll likely find this syntax most beneficial.

Some specific differences between the two languages are as follows:

Table 17.1. Differences Between Crystal and Basic Syntax

Description

Crystal

Basic

Variable declarations

StringVar

Dim

Statement endings

;

None required

Comment characters

//

'

Variable assignment

=

=

Formula statement

None required

required

Formula returns

None required

Return statement

Multiline statement indicators

None required

_

If statement ending

None required

End If

Why Was the Basic Syntax Added?

Many functions and operators provided by the Basic language would make Crystal Reports users more productive. By implementing the whole language, the existing Crystal syntax users could benefit from the new operators and functions and at the same time: Newer users who are familiar with the Basic language through other development endeavors could easily make the jump to creating formulas in Crystal Reports.

Some of the functions and operators that were added as a result of the addition of the Basic syntax are

  • Date functions such as DateAdd, DateDiff, and DateSerial

  • Financial functions such as Present Value (PV)

  • Control structures such as Do While, Do Until, and For Next statements

Selecting the Best Syntax for You

Whether you choose Basic or Crystal syntax, they are both equally capable of doing the job and there is no performance implication in making this choice. The decision is entirely based on the comfort level and familiarity of each language for report designers.

graphics/lightbulb_icon.gif

Whichever syntax is your ideal, you can set it up as the default for all new formulas by going to File, Options, Reporting, and choosing the desired syntax in the Formula Language list box.




Sams Teach Yourself Crystal Reports 9 in 24 Hours
Sams Teach Yourself Crystal Reports 9 in 24 Hours
ISBN: B003D7JUVW
EAN: N/A
Year: 2005
Pages: 230

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net