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
IF A=B AND B=C
&&
if( ( a == b )&&( b == c ) )
OR
IF A=B OR A=C
||
if( ( a == b ) || ( a == c ) )
NOT
IF NOT B
!
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
Содержание VT1419A Multifunction Plus
Страница 5: ...4 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 15: ...14 Contents Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 25: ...24 Chapter 1 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 173: ...Notes 172 Chapter 5 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 332: ...332 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 333: ...Appendix A 333 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 334: ...334 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 335: ...Appendix A 335 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 336: ...336 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 337: ...Appendix A 337 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 338: ...338 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 339: ...Appendix A 339 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 340: ...340 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 341: ...Appendix A 341 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 342: ...342 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 343: ...Appendix A 343 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 344: ...344 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 345: ...Appendix A 345 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 346: ...346 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 347: ...Appendix A 347 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 348: ...348 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 349: ...Appendix A 349 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 350: ...350 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 351: ...Appendix A 351 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 352: ...352 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 353: ...Appendix A 353 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 354: ...354 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 355: ...Appendix A 355 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 356: ...356 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 357: ...Appendix A 357 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 358: ...358 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 370: ...Notes 370 Appendix C Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...