RPC HELP M Entry Examples

From VistApedia
Revision as of 01:31, 6 July 2015 by Kdtop (talk | contribs)
(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