In the User Function window:
Return Type: |
Single |
Input Parameters: |
long a; short b; |
Output Parameters: |
char w[1]; long y; char x[30]; long z; |
In the state table:
STRING func3_char, NUMBER func3_long1, NUMBER func3_long2, STRING func3_string, NUMBER send3_long, NUMBER send3_short; AssignData(send3_long, "ASSIGN", "300") ; AssignData(send3_short, "ASSIGN", "20") ; SendData("CUSTOM_SERVER", "TEST_PARMS", 30, "TEST_PARMS_func3", "send3_long", "send3_short") ; ReceiveData("CUSTOM_SERVER", "TEST_PARMS", 30, "TEST_PARMS_func3", func3_char, func3_long1, func3_string, func3_long2) ;
So, using the data in SendData (above), the parameters in ReceiveData have the following values:
Example code
char *TEST_PARMS_func3 (long a, short b) { char w; char *x; long y; long z; char *buf_ptr; if (a == 100) { w = 'l'; y = 123; if (b == 2) { x = "San Francisco"; z = 10000; } else { x = "Los Angeles"; z = 20000; } /* endif */ } else { w = 'g'; y = 456; if (b == 2) { x = "Houston"; z = 30000; } else { x = "New York"; z = 40000; } /* endif */ } /* endif */ /******************************************************************* Put data items to be returned to state table into buffer. Note TP_buffer must be declared so the data is persistent until the statement if (CA_Put_DT_Parameters ( &DT_msg_info_st, TEST_PARMS_func3_output_ptr) ... in the main function. Once CA_Put_DT_Parameters has returned, the storage can be reused. In this case TP_buffer is a global in the source module containing the user functions, for example, char TP_buffer[100]; ***********************************************************************/ buf_ptr = TP_buffer; *buf_ptr = w; buf_ptr += sizeof(w); *(long *)buf_ptr = y; buf_ptr += sizeof (y); strcpy (buf_ptr, x); buf_ptr += strlen(x) + 1; *(long *)buf_ptr = z; return(TP_buffer); }