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
     S RESULT=A+B
     Q
  2. This example receives an array of numbers and returns them as a sorted array to the client:
    SORT(RESULT,UNSORTED)	;sort numbers
     N I
     S I=""
     F  S I=$O(UNSORTED(I)) Q:I=""  S RESULT(UNSORTED(I))=UNSORTED(I)
     Q