Example 7 - a non-volatile array program, Example 7 - a non-volatile array program -17 – Rockwell Automation 2098-IPD-xxx Ultra5000 C Programming using the Motion Library User Manual
Page 29

Publication 2098-PM001E-EN-P — July 2002
Programming Motion Control in C
1-17
controller’s non-volatile memory but only one of each type may be
accessed at a time. One way to access non-volatile arrays is shown.
Example 7 - A Non-Volatile Array Program
#include <motion.h>
/* This program assumes that two 10-element arrays have been
created through Ultraware. One floating-point array named
"FArray" and one long integer array named "IArray". This
program continuously cycles through the array elements
incrementing the value to be written. */
int main (void)
{
long loopcount=0;
long i;
InitMotionLibrary();
FloatArraySelect("FArray");
LongArraySelect("IArray");
while (!StopRequested())
{
for (i=0; i <= 9; i++){
LongArraySetElement(i,(loopcount*10)+i);
/* Set a long integer
value */
FloatArraySetElement(i,loopcount+((float)i/10));
/* Set a floating-point
value */
Sleep(200);
/* Take a rest for 200
milliseconds so the
updates can be easily
seen in Ultraware */
}
loopcount++;
}
return 0;
}
Notice that in the line
FloatArraySetElement(i,loopcount+((float)i/10));
the expression i/10 has the type in brackets right before it.