1 | %ZOSV2 ;ISF/RWF - More GT.M support routines ;10/18/06 14:29
|
---|
2 | ;;8.0;KERNEL;**275,425**;Jul 10, 1995;Build 4;WorldVistA 30-Jan-08
|
---|
3 | ;Modified from FOIA VISTA,
|
---|
4 | ;Copyright 2008 WorldVistA. Licensed under the terms of the GNU
|
---|
5 | ;General Public License See attached copy of the License.
|
---|
6 | ;
|
---|
7 | ;This program is free software; you can redistribute it and/or modify
|
---|
8 | ;it under the terms of the GNU General Public License as published by
|
---|
9 | ;the Free Software Foundation; either version 2 of the License, or
|
---|
10 | ;(at your option) any later version.
|
---|
11 | ;
|
---|
12 | ;This program is distributed in the hope that it will be useful,
|
---|
13 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | ;GNU General Public License for more details.
|
---|
16 | ;
|
---|
17 | ;You should have received a copy of the GNU General Public License along
|
---|
18 | ;with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
19 | ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
---|
20 | Q
|
---|
21 | ;SAVE: DIE open array reference.
|
---|
22 | ; XCN is the starting value to $O from.
|
---|
23 | SAVE(RN) ;Save a routine
|
---|
24 | N %,%F,%I,%N,SP,$ETRAP
|
---|
25 | S $ETRAP="S $ECODE="""" Q"
|
---|
26 | S %I=$I,SP=" ",%F=$$RTNDIR^%ZOSV()_$TR(RN,"%","_")_".m"
|
---|
27 | O %F:(newversion:noreadonly:blocksize=2048:recordsize=2044) U %F
|
---|
28 | F S XCN=$O(@(DIE_XCN_")")) Q:XCN'>0 S %=@(DIE_XCN_",0)") Q:$E(%,1)="$" I $E(%)'=";" W $P(%,SP)_$C(9)_$P(%,SP,2,99999),!
|
---|
29 | C %F ;S %N=$$NULL
|
---|
30 | ZLINK RN
|
---|
31 | ;C %N
|
---|
32 | U %I
|
---|
33 | Q
|
---|
34 | NULL() ;Open and use null to hide talking. Return open name
|
---|
35 | ;Doesn't work for compile errors
|
---|
36 | N %N S %N=$S($ZV["VMS":"NLA0:",1:"/dev/nul")
|
---|
37 | O %N U %N
|
---|
38 | Q %N
|
---|
39 | ;
|
---|
40 | DEL(RN) ;Delete a routine file, both source and object.
|
---|
41 | N %N,%DIR,%I,$ETRAP
|
---|
42 | S $ETRAP="S $ECODE="""" Q"
|
---|
43 | S %I=$I,%DIR=$$RTNDIR^%ZOSV,RN=$TR(RN,"%","_")
|
---|
44 | I $L($ZSEARCH(%DIR_RN_".m",244)) ZSYSTEM "rm -f "_%DIR_X_".m"
|
---|
45 | I $L($ZSEARCH(%DIR_RN_".obj",244)) ZSYSTEM "rm -f "_%DIR_X_".obj"
|
---|
46 | I $L($ZSEARCH(%DIR_RN_".o",244)) ZSYSTEM "rm -f "_%DIR_X_".o"
|
---|
47 | Q
|
---|
48 | ;LOAD: DIF open array to receive the routine lines.
|
---|
49 | ; XCNP The starting index -1.
|
---|
50 | LOAD(RN) ;Load a routine
|
---|
51 | N %
|
---|
52 | S %N=0 F XCNP=XCNP+1:1 S %N=%N+1,%=$T(+%N^@RN) Q:$L(%)=0 S @(DIF_XCNP_",0)")=%
|
---|
53 | Q
|
---|
54 | ;
|
---|
55 | LOAD2(RN) ;Load a routine
|
---|
56 | N %,%1,%F,%N,$ETRAP
|
---|
57 | S %I=$I,%F=$$RTNDIR^%ZOSV()_$TR(RN,"%","_")_".m"
|
---|
58 | O %F:(readonly):1 Q:'$T U %F
|
---|
59 | F XCNP=XCNP+1:1 R %1:1 Q:'$T!$ZEOF S @(DIF_XCNP_",0)")=$TR(%1,$C(9)," ")
|
---|
60 | C %F I $L(%I) U %I
|
---|
61 | Q
|
---|
62 | ;
|
---|
63 | RSUM(RN) ;Calculate a RSUM value
|
---|
64 | N %,DIF,XCNP,%N,Y,$ETRAP K ^TMP("RSUM",$J)
|
---|
65 | S $ETRAP="S $ECODE="""" Q"
|
---|
66 | S Y=0,DIF="^TMP(""RSUM"",$J,",XCNP=0 D LOAD2(RN)
|
---|
67 | F %=1,3:1 S %1=$G(^TMP("RSUM",$J,%,0)),%3=$F(%1," ") Q:'%3 S %3=$S($E(%1,%3)'=";":$L(%1),$E(%1,%3+1)=";":$L(%1),1:%3-2) F %2=1:1:%3 S Y=$A(%1,%2)*%2+Y
|
---|
68 | K ^TMP("RSUM",$J)
|
---|
69 | Q Y
|
---|
70 | ;
|
---|
71 | RSUM2(RN) ;Calculate a RSUM2 value
|
---|
72 | N %,DIF,XCNP,%N,Y,$ETRAP K ^TMP("RSUM",$J)
|
---|
73 | S $ETRAP="S $ECODE="""" Q"
|
---|
74 | S Y=0,DIF="^TMP(""RSUM"",$J,",XCNP=0 D LOAD2(RN)
|
---|
75 | F %=1,3:1 S %1=$G(^TMP("RSUM",$J,%,0)),%3=$F(%1," ") Q:'%3 S %3=$S($E(%1,%3)'=";":$L(%1),$E(%1,%3+1)=";":$L(%1),1:%3-2) F %2=1:1:%3 S Y=$A(%1,%2)*(%2+%)+Y
|
---|
76 | K ^TMP("RSUM",$J)
|
---|
77 | Q Y
|
---|
78 | ;
|
---|
79 | TEST(RN) ;Special GT.M Test to see if routine is here.
|
---|
80 | N %F,%X
|
---|
81 | S %F=$$RTNDIR^%ZOSV()_$TR(RN,"%","_")_".m"
|
---|
82 | S %X=$ZSEARCH("X.X",245),%X=$ZSEARCH(%F,245)
|
---|
83 | Q %X
|
---|