forked from jasonli2000/VistA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZGI.m
72 lines (72 loc) · 2.23 KB
/
ZGI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
ZGI ; Read Globals from ZWR format
;---------------------------------------------------------------------------
; Copyright 2011 The Open Source Electronic Health Record Agent
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;---------------------------------------------------------------------------
N D CONFIG
W "ZWR Global Input",! X CONFIG("ASKIO") Q:IO="" W !
I '$$LOAD(IO) Q
U $P W "Loaded "_IO,!
Q
LOAD(IO) ; Read Globals from IO device in ZWR format
N CONFIG D CONFIG
N Q,S S Q=1
C IO X CONFIG("OPENIO") I '$T W "Failed to open: "_IO,! Q 0
I '($$READLINE(.H1)&$$READLINE(.H2)&(H2["ZWR")) U $P W "Not a ZWR: "_IO,! S Q=0 G QUIT
F Q:'$$READLINE(.S) S @S
G QUIT
LIST(IO,DIR) ; Read list from IO, load Globals from each DIR<entry> device
N CONFIG D CONFIG
N Q,ZWR S Q=1
S DIR=$G(DIR,"")
C IO X CONFIG("OPENIO") I '$T W "Failed to open: "_IO,! Q 0
F Q:'$$READLINE(.ZWR) U $P W DIR_ZWR,! I '$$LOAD(DIR_ZWR) S Q=0
G QUIT
;---------------------------------------------------------------------------
; Private implementation entry points below
;
READLINE(LINE)
N $ES,$ET,EOF S EOF=0 X CONFIG("ETRAP")
D READLN(.LINE)
Q '($ZEOF!EOF)
READLN(LINE)
S LINE=""
U IO R LINE
Q
ETRAP
I @(CONFIG("ENDOFFILE")) S EOF=-1
S $EC=""
Q
QUIT
C IO
Q Q
CONFIG
I $D(CONFIG) Q
I $ZV["Cache" D Q
. S CONFIG("ASKIO")="D IN^%IS I POP S IO="""""
. S CONFIG("OPENIO")="O IO:(""R""):0"
. S CONFIG("ETRAP")="S $ET=""G ETRAP"""
. S CONFIG("ENDOFFILE")="$ZE[""ENDOFFILE"""
I $ZV["GT.M" D Q
. S CONFIG("ASKIO")="D ASKIO"
. S CONFIG("OPENIO")="O IO:(readonly):0"
. S CONFIG("ETRAP")="U IO:(exception=""G ETRAP"")"
. S CONFIG("ENDOFFILE")="$ZS[""IOEOF"""
W "ZGI does not support "_$ZV,!
Q
ASKIO
R "Device: ",IO,!
I IO="" G ASKIO
I IO="^" S IO=""
Q