Difference between revisions of "RPC HELP M Entry Examples"

From VistApedia
Jump to: navigation, search
(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...")
 
 
Line 7: Line 7:
  
 
     SUM(RESULT,A,B) ;add two numbers
 
     SUM(RESULT,A,B) ;add two numbers
       SET RESULT=A+B
+
       '''SET''' RESULT=A+B
       QUIT
+
       '''QUIT'''
 
 
  
Line 14: Line 14:
 
 
 
     SORT(RESULT,UNSORTED) ;sort numbers
 
     SORT(RESULT,UNSORTED) ;sort numbers
    NEW I
+
      '''NEW''' I
    SET I=""
+
      '''SET''' I=""
    FOR SET I=$O(UNSORTED(I)) QUIT:I="" SET RESULT(UNSORTED(I))=UNSORTED(I)
+
      '''FOR SET''' I=$O(UNSORTED(I)) '''QUIT''':I="" '''SET''' RESULT(UNSORTED(I))=UNSORTED(I)
    QUIT
+
      '''QUIT'''

Latest revision as of 01:31, 6 July 2015

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