RPC HELP M Entry Examples

From VistApedia
Revision as of 01:30, 6 July 2015 by Kdtop (talk | contribs) (Created page with " RPC Broker Help Home <h2>Examples</h2> The following two examples illustrate sample M code that could be used in simple RPCs. 1. This example takes two...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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