Specifications
Overall Program
Structure
The preceding discussion showed the differences between individual statements in
BASIC and ‘C.’ The following shows how the VT1419A’s Algorithm Language
elements are arranged into a program.
Here is a simple example algorithm that shows most of the elements discussed so
far.
/* Example Algorithm to show language elements in the context of a complete
custom algorithm.
Program variables:
user_flag Set this value with the SCPI command ALG:SCALAR.
user_value Set this value with the SCPI command ALG:SCALAR.
Program Function:
Algorithm returns user_flag in CVT element 330 and another value in CVT element 331
each time the algorithm is executed.
When user_flag = 0, returns zero in CVT 331.
When user_flag is positive, returns user_value*2inCVT331
When user_flag is negative, returns user_value/2inCVT331andinFIFO
Use the SCPI command ALGorithm:SCALar followed by ALGorithm:UPDate to set
user_flag and user_value.
*/
static float user_flag = 0; /* user_flag will be initialized to 0 when alg is defined, not when run */
static float user_value; /* Declaration statements (end with ; ) */
writecvt (user_flag,330); /* Always write user_flag in CVT (statement ends with;)*/
if (user_flag ) /* if statement (note no;)*/
The Algorithm Language and Environment
Program Structure and Syntax
Chapter 4 137
Figure 4-4: Examples of 'C' and BASIC if Statements
if(a <= 0) c=abs(a);
if(a != 0)
c=b/a;
if((a != b) && (a != c))
{
a=a*b;
b=b+1;
c=0;
}
if((a == 5) || (b == -5))
{
c = abs(c);
c=2/c;
}
else
{
c=a*b;
}
IF A<=0 THEN C=ABS(A)
IF A<>0 THEN
C=B/A
END IF
IF A<>B AND A<>C THEN
A=A*B
B=B+1
C=0
END IF
IF A=5 OR B=-5 THEN
C=ABS(C)
C= 2/C
ELSE
C= A*B
END IF
ExamplesBASIC Syntax ‘C’ Syntax
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com










