In the User Function window:
Return Type: |
Multiple |
Input Parameters: |
long a; struct b { long aa; char bb[20]; short cc; }; |
Output Parameters: |
struct ST2 { long x; long y; char z[1]; }; |
In the state table:
STRING func9_char, NUMBER func9_long1, NUMBER func9_long2, STRING send1_char, NUMBER send3_long, STRING send3_short, NUMBER send9_long; AssignData(send3_long, "ASSIGN", "10") ; AssignData(send9_long, "ASSIGN", "1") ; AssignData(send1_char, "ASSIGN", "f9") ; AssignData(send3_short, "ASSIGN", "2") ; SendData("CUSTOM_SERVER", "TEST_PARMS", 30, "TEST_PARMS_func9", send3_long, send9_long, send1_char, send3_short) ; ReceiveData("CUSTOM_SERVER", "TEST_PARMS", 30, "TEST_PARMS_func9", func9_long1, func9_long2, func9_char) ;
So, using the data in SendData (above), the values for successive ReceiveData actions are:
func9_long1 |
func9_long2 |
func9_char |
100 |
3 |
f |
200 |
4 |
f |
300 |
5 |
f |
400 |
6 |
f |
A fifth ReceiveData has the edge EDGE_RECEIVE_DATA_NO_MORE_DATA.
Example code
char *TEST_PARMS_func9 (a, b) long a; /* System generated structure typedef in TEST_PARMS_hdr.h from information entered into the User Function Panel of the GUI */ TEST_PARMS_func9_1_ST *b; { long count; /* will return this number of groups */ TEST_PARMS_func9_2_ST *st_ptr; /* System Generated */ long i; char *buf_ptr; if (a > 4) { count = 4; } else if (a < 1) { count = 1; } else { count = a; } /* endif */ buf_ptr = TP_buffer; /* * Multiple return the first element MUST be the number of multiples */ *(long *)buf_ptr = count; buf_ptr += sizeof(count); st_ptr = (TEST_PARMS_func9_2_ST *)buf_ptr; /* * Put each iteration in to the return buffer */ for (i = 1; i <= count; i++) { st_ptr->TEST_PARMS_func9_x = a * 10 * i; st_ptr->TEST_PARMS_func9_y = b->TEST_PARMS_func9_aa * b->TEST_PARMS_func9_cc + i; st_ptr->TEST_PARMS_func9_z = b->TEST_PARMS_func9_bb[0]; st_ptr++; } /* endfor */ return(TP_buffer); }