RPC HELP M Entry Examples

RPC Broker Help Home Examples

The following two examples illustrate sample M code that could be used in simple RPCs. 1. This example takes two numbers and returns their sum:

SUM(RESULT,A,B) ;add two numbers SET RESULT=A+B QUIT

2. This example receives an array of numbers and returns them as a sorted array to the client: SORT(RESULT,UNSORTED) ;sort numbers NEW I     SET I="" FOR SET I=$O(UNSORTED(I)) QUIT:I="" SET RESULT(UNSORTED(I))=UNSORTED(I) QUIT