Invalid definition example, C example, Basic example – Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual

Page 218: References

Advertising
background image

API Library of Routines

Appendix B

B-87

Invalid Definition Example

DTL_C_DEFINE (&idl, “N34:3”)

/* not specified to element 0 */

DTL_C_DEFINE (&idl, “N34:0,3,long”) /* number of items not 1 */

C Example

unsigned machine;

unsigned short parts[10];

unsigned iostat;

DTL_C_DEFINE (&machine, “N20:0, 1, WORD, MODIFY”);

DTL_WRITE_W_IDX (machine, &parts[3], &iostat, 3) /* read element N20:3 */

DTL_WRITE_W_IDX (machine, &parts[8], &iostat, 8) /* read element N20:8 */

BASIC Example

The BASIC function code is 21.

procedure COPRO

DIM status : INTEGER

DIM id : INTEGER

DIM iostat : INTEGER

DIM val3 : INTEGER

DIM val8 : INTEGER

.

.

.

rem * Define the data file

RUN AB_BAS (2, status, ADDR(id), “N10:0, 1, LONG, MODIFY”)

rem * Write val3 to N10:3

RUN AB_BAS (21, status, id, ADDR(val3), ADDR(iostat), 3)

rem * Write val8 to N10:8

RUN AB_BAS (21, status, id, ADDR(val8), ADDR(iostat), 8)

.

.

.

References

DTL_C_DEFINE(); DTL_READ_W_IDX(); DTL_RMW_W_IDX();

Advertising