Choosing a Formula Language: Crystal Versus Basic Syntax

Choosing a Formula Language Crystal Versus Basic Syntax

In previous chapters, 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 used language, but the Basic syntax is also available.

Both languages are equal in their functionalitymeaning that if something was added to Crystal syntax, it was also added to Basic. The reason you're given a choice is for your comfortyou can use whichever language you are more comfortable with using.

Understanding 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 described in Table 13.1.

Table 13.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

;

End If

 

Why Basic Syntax Was Added

Many functions and operators provided by the Basic language increase the productivity of Crystal Reports users. 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

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.

TIP

Whichever syntax you prefer to use most often, 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.

Категории