User`s manual

Dynamic C Users Manual digi.com 61
Content
The content field (a union) is used by the costatement or cofunction delay routines to store a delay
count.
Check Sum 2
The ChkSum2 field is currently unused.
5.4.3 Pointer to CoData Structure
To obtain a pointer to a named costatement’s CoData structure, do the following:
The storage class of a named CoData structure must be static.
5.4.4 Functions for Use With Named Costatements
For detailed function descriptions, please see the Dynamic C Function Reference Manual or select Func-
tion Lookup/Insert from Dynamic C’s Help menu (keyboard shortcut is <Ctrl-H>).
All of these functions are in COSTATE.LIB. Each one takes a pointer to a CoData struct as its only
parameter.
int isCoDone(CoData* p);
This function returns true if the costatement point to by p is initialized and not running.
int isCoRunning(CoData* p);
This function returns true if the costatement pointed to by p will run if given a continuation call.
void CoBegin(CoData* p);
This function initializes a costatement’s CoData structure so that the costatement will be execut-
ed next time it is encountered.
void CoPause(CoData* p);
This function will change CoData so that the associated costatement is paused. When a cos-
tatement is called in this state it does an implicit yield until it is released by a call from
CoResume or CoBegin.
void CoReset(CoData* p);
This function initializes a costatement’s CoData structure so that the costatement will not be ex-
ecuted the next time it is encountered unless the costatement is declared always_on.
void CoResume(CoData* p);
This function unpauses a paused costatement. The costatement resumes the next time it is called.
static CoData cost1; // allocate memory for a CoData struct
static CoData *pcost1;
pcost1 = &cost1; // get pointer to the CoData struct
...
CoBegin (pcost1); // initialize CoData struct
costate pcost1 { // pcost1 is the costatement name and also a
... // pointer to its CoData structure.
}