Specifications

NOTE In BASIC the assignment symbol “=” is also used as the comparison operator “is
equal to.” For example, IF a=b THEN ... . As is shown later in this chapter, ‘C’ uses
a different symbol for this comparison.
The Operations
Symbols
Many of the operation symbols are the same and are used the same way as those in
BASIC. However, there are differences and they can cause programming errors
until they are understood.
The Arithmetic
Operators
The arithmetic operators available to the VT1419A are the same as those
equivalents in BASIC:
+ (addition) - (subtraction)
* (multiplication) / (division)
Unary Arithmetic
Operator
Again same as BASIC:
- (unary minus) Examples:
a=b+(-c)
+ (unary plus) a=c+(+b)
The Comparison
Operators
Here there are some differences.
BASIC ‘C’ Notes
= (is equal to) == Different (hard to remember)
<> or # (is not equal to) != Different but obvious
> (is greater than) > Same
< (is less than) > Same
>= (is greater than or equal to) >= Same
<= (is less than or equal to) <= Same
A common ‘C’ programming error for BASIC programmers is to inadvertently use
the assignment operator “=” instead of the comparison operator “==” in an if
statement. Fortunately, the VT1419A will flag this as a Syntax Error when the
algorithm is loaded.
The Logical Operators There are three operators. They are very different from those in BASIC.
BASIC Examples ‘C’ Examples
AND IFA=BANDB=C && if((a==b)&&(b==c))
OR IFA=BORA=C || if((a==b)||(a==c))
NOT IFNOTB ! if(!b)
Conditional
Execution
The VT1419A Algorithm Language provides the if - else construct for conditional
execution. The following figure compares the elements of the ‘C’ if - else construct
with the BASIC if - then - else - end if construct. The general form of the if - else
construct is:
if(expression) statement1 else statement2
where statement1 is executed if expression evaluates to non-zero (true) and
statement2 is executed if expression evaluates to zero (false). Statement1 and/or
statement2 can be compound statements. That is, multiple simple statements within
curly braces. See Figure 4-3.
The Algorithm Language and Environment
Program Structure and Syntax
134 Chapter 4
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com