beautypg.com

Date and time stamp – Rockwell Automation 6008-SI IBM PC I/O SCNNR 6008-SI User Manual

Page 110

background image

Chapter 9

General Support Features

9-3

If your timing loop actually does something, you might write it this way:

for ( g_decrem=19; g_decrem>0 && ...; ) {

/* loop action here */

}

As shown above, you can end the loop when it times out or when some
other condition occurs.

In this section we provide three routines to access the system date and time
in convenient form.

sysdate

returns the system date in the form yymmdd.

Calling sequence:

ldate = sysdate(

date_array

);

Arguments:

a short[3] array, or a NULL pointer.

CAUTION: Unless the argument is zero (the defined constant
NULL), sysdate treats it as a pointer and writes data to the first
six bytes it points to. If the argument is not in fact a pointer, the
user program could crash or have unpredictable results.

Returned values:

ldate, a long integer: the system date in year-month-day format, such as

900612.

If the array argument is provided, this routine puts the year (modulo
1900), month, and day in the three cells of the array. You could then
display the date in any desired format by coding such as this:

char *month[12] = { “January”, ..., “December” };
short date[3];
long ldate;

. . .

ldate = sysdate(date);
printf(“%d = %s %d, %d”, ldate,

month[date[1]], date[2], 1900+date[0]);

Date and

Time Stamp