source: WorldVistAEHR/trunk/r/RPC_BROKER-XWB/XWBEXMPL.m@ 862

Last change on this file since 862 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 2.3 KB
Line 
1XWBEXMPL ;ISC-SF/VYD - RPC BROKER EXAMPLE ;07/13/2004 15:03
2 ;;1.1;RPC BROKER;**22,35**;Mar 28, 1997
3ECHOSTR(RESULT,OSTRING) ;receive string and return it
4 S RESULT=OSTRING
5 Q
6 ;
7 ;
8GETLIST(RESULT,WHAT,QTY) ; -- return list
9 ;WHAT - LINES or KILOBYTES, QTY - number of lines of kilobytes
10 ;here the resulting list can get quite large - use global structure
11 N I,J,L,V ;looping vars
12 S $P(L,"-+",128)=" "
13 K ^TMP($J,"XWB RESULTS") ;clean out temporary storage
14 I WHAT="LINES" D ;lines requested
15 . F I=1:1:QTY D
16 . . S V="Line #"_I,V=V_$S(I'>$L(V):"",1:$E(L,1,$S(QTY+$L(V)>255:255-$L(V),1:QTY-$L(V))))
17 . . S ^TMP($J,"XWB RESULTS",I)=V
18 . . ;S ^TMP($J,"XWB RESULTS",I)="Line #"_I
19 ;
20 E D ;kilobytes of data requested
21 . F I=1:1:QTY D
22 . . F J=1:1:64 D ;64 lines * 16 chars = 1K
23 . . . S ^TMP($J,"XWB RESULTS",I*100+J)=$E(I_"-Kilobyte******",1,16)
24 ;
25 S RESULT=$NA(^TMP($J,"XWB RESULTS")) ;give Broker data root
26 Q
27 ;
28 ;
29WPTEXT(RESULT) ;return word processing text
30 N TEXT
31 ;use DBS call to get REMOTE PROCEDURE file description
32 D FILE^DID(8994,"","DESCRIPTION","TEXT")
33 M RESULT=TEXT("DESCRIPTION")
34 Q
35 ;
36 ;
37SORTNUM(RESULT,DIRCTN,ARRAY) ; -- sort numbers and return sorted
38 ;DIRCTN - direction to sort in HI or LO
39 ;ARRAY - array of numbers to sort
40 ;S $ECODE=",U411," Q
41 N I,J
42 IF DIRCTN="LO" D ;sort LOW -> HIGH
43 . S I="" F S I=$O(ARRAY(I)) Q:I="" S J=ARRAY(I) D
44 . . S RESULT(J)=J
45 . . S JLIN=$G(JLIN)+1,^TMP("JLI",JLIN)=I_U_J
46 E D ;sort HIGH -> LOW
47 . S I="" F S I=$O(ARRAY(I)) Q:I="" S J=ARRAY(I) D
48 . . S RESULT(99999999-J)=J
49 Q
50 ;
51GSORT(RESULT,DIRCTN,ROOT) ; -- Sort numbers in a global array
52 ;DIRCTN - direction to sort in HI or LO
53 ;ROOT - Closed Root of the Global array of numbers to sort
54 ;Data is in ^TMP("XWB",$J,n)
55 N I,V K ^TMP($J)
56 IF DIRCTN="LO" D ;sort LOW -> HIGH
57 . S I="" F S I=$O(@ROOT@(I)) Q:I="" D
58 . . S V=$G(@ROOT@(I)) I $L(V) S ^TMP($J,V)=V
59 E D ;sort HIGH -> LOW
60 . S I="" F S I=$O(@ROOT@(I)) Q:I="" D
61 . . S V=$G(@ROOT@(I)) I $L(V) S ^TMP($J,99999999-V)=V
62 S RESULT=$NA(^TMP($J))
63 M ^RWF($J)=@ROOT
64 Q
65 ;
66BIGTXT(RESULT,ARRAY) ;-- Accept a big text block.
67 ;Return count. char^lines
68 N CC,LC,I
69 S CC=0,LC=0,I=""
70 F S I=$O(ARRAY(I)) Q:I="" S LC=LC+1,CC=CC+$L(ARRAY(I))
71 K ^TMP($J) M ^TMP($J)=ARRAY
72 S RESULT=CC_"^"_LC
73 Q
Note: See TracBrowser for help on using the repository browser.