source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/ZISHMSU.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: 7.0 KB
Line 
1%ZISH ;IHS/PR,SFISC/AC - HOST COMMANDS - MSM UNIX ;10/15/96 11:11
2 ;;8.0;KERNEL;;JUL 10, 1995
3 ;
4 ;
5OPEN(X1,X2,X3,X4) ;
6 ;X1=handle name
7 ;X2=directory name /dir/
8 ;X3=file name
9 ;X4=file access mode e.g.: W for write, R for read, A for append.
10 N %,%1,%I
11 S %I=$I
12 F %=51:1:54 O %::0 S %T=$T Q:%T
13 I %T S IO=%,IO(1,IO)="",POP=0
14 E U:$D(IO(1,%I) %I S POP=1 Q
15 S %1=$$MODE^%ZISF(X2_X3,X4)
16 S %=%_":"_%1
17 U @% S %ZA=$ZA
18 I %ZA=-1 U %I C IO K IO(1,IO) S POP=1 Q ;Q 0
19 ;S IO=%,IO(1,IO)=""
20 I $G(X1)]"" D SAVDEV^%ZISUTL(X1)
21 Q ;Q 1
22 ;
23CLOSE(X) ;Close HFS device not opened by %ZIS.
24 ;X=HANDLE NAME
25 N %
26 I $G(X)]"" C IO K IO(1,IO) D RMDEV^%ZISUTL(X),HOME^%ZIS Q
27 C IO K IO(1,IO) D HOME^%ZIS
28 Q
29 ;
30OPENERR ;
31 Q 0
32 ;
33DEL(%ZISHX1,%ZISHX2) ;Del fl(s)
34 ;S Y=$$DEL^ZOSHMSM("/dir/","fl")
35 ; ,.array)
36 ;Changed param 2 to a $NAME string.
37 N %ZISH,%ZISHLGR
38 N ZOSHDA,ZOSHF,ZOSHX,ZOSHQ,ZOSHDF,ZOSHC
39 ;
40 ;Dir frmt
41 ;D DF(.ZOSH1) CHANGE TO USE $TR
42 S %ZISHX1=$TR(%ZISHX1,"\","/")
43 ;
44 ;Get fls to act on
45 ;No '*' allowed
46 S %ZISHLGR=$$LGR^%ZOSV ;if possible, save off last global reference
47 S %ZISH="" F S %ZISH=$O(@%ZISHX2@(%ZISH)) Q:'%ZISH I %ZISH["*" S ZOSHQ=1 Q
48 I $D(ZOSHQ) X "I $G(%ZISHLGR)]"""",$D(@%ZISHLGR)" Q 0
49 S %ZISH="" F S %ZISH=$O(@%ZISHX2@(%ZISH)) Q:%ZISH="" D
50 .S ZOSHC="rm "_%ZISHX1_%ZISH
51 .;S ZOSHC=$ZOS(2,%ZOSHX1_%ZISH)
52 .D JW
53 I $G(%ZISHLGR)]"",$D(@%ZISHLGR)
54 Q 1
55 ;
56 ;
57LIST(%ZISHX1,%ZISHX2,%ZISHX3) ;Create a local array holding fl names
58 ;S Y=$$LIST^ZOSHDOS("\dir\","fl",".return array")
59 ; "fl*",
60 ; .array,
61 ;
62 ;Change X2 = $NAME OF CLOSE ROOT
63 ;Change X3 = $NAME OF CLOSE ROOT
64 ;
65 N %ZISH,%ZISHLGR,%ZISHN,%ZISHX,%ZISXX,%ZISHY
66 S %ZISHLGR=$$LGR^%ZOSV ;if possible, save off last global reference
67 S ZOSHC="rm ZOSHAUTO."_$J
68 D JW
69 S %ZISHN=0
70 ;Get fls to act on
71 S %ZISH="" F S %ZISH=$O(@%ZISHX2@(%ZISH)) Q:%ZISH="" D
72 .S %ZISHX=%ZISHX1_%ZISH
73 .S ZOSHC="ls -d "_%ZISHX_" >> ZOSHAUTO."_$J
74 .D JW
75 D OPEN("","","ZOSHAUTO."_$J,"R")
76 F ZOSHLN=1:1 U IO R %ZISHXX Q:$$STATUS=-1 D
77 .S %ZISHY=$P(%ZISHXX,"/",$L(%ZISHXX,"/"))
78 .I %ZISHY]"" S @%ZISHX3@(%ZISHY)=""
79 C IO K IO(1,IO)
80 ;Remove ZOSHAUTO.$J
81 S ZOSHC="rm ZOSHAUTO."_$J
82 D JW
83 I $G(%ZISHLGR)]"",$D(@%ZISHLGR)
84 Q $O(@%ZISHX3@(""))]""
85 ;
86MV(X1,X2,X3,X4) ;Rename a fl
87 ;S Y=$$MV^ZOSHMSM("/dir/","fl","/dir/","fl")
88 ;
89 N %,%1
90 N ZOSHC,ZOSHX
91 ;
92 ;Dir frmt
93 D DF(.X1)
94 D DF(.X3)
95 ;
96 ;Pbv or qit
97 I $O(X2(0))!($O(X4(0))) S ZOSHX=3 X "I $G(%ZISHLGR)]"""",$D(@%ZISHLGR)" Q ZOSHX
98 ;
99 ;Check for 'from' and 'to' directory
100 ;
101 ;S ZOSHC="mv "_X1_X2_" "_X3_X4
102 S ZOSHC="cp "_X1_X2_" "_X3_X4_" ; rm "_X1_X2
103 D JW
104 I $G(%ZISHLGR)]"",$D(@%ZISHLGR)
105 Q 1 ;ZOSHX
106 ;
107PWD() ;Print working directory
108 ;
109 N %,%IS,POP,X,Y,ZOSHC,ZOSHDA,ZOSHDF,ZOSHF,ZOSHIOP,ZOSHLN,ZOSHQ,ZOSHX,ZOSHSYFI,ZOSHIOP1
110 ;
111 ;Init ZOSHAUTO.$J
112 S ZOSHC="rm ZOSHAUTO."_$J
113 D JW
114 ;
115 S ZOSHC="pwd > ZOSHAUTO."_$J
116 D JW
117 ;
118 ;Open ZOSHAUTO.$J to read.
119 ;Create the 'Return Array' to pass back to user
120 D OPEN^%ZISH("","ZOSHAUTO."_$J,"R") I POP Q ""
121 F %1=1:1 U IO R % Q:$$STATUS=-1 S Y=%
122 D CLOSE^%ZISH("")
123 ;
124 ;Remove ZOSHAUTO.$J
125 S ZOSHC="rm ZOSHAUTO."_$J
126 D JW
127 ;
128 S Y=Y_$S($E(Y,$L(Y))'="/":"/",1:"")
129 Q Y
130 ;
131JW ;msm extrinsic
132 S ZOSHX=$$JOBWAIT^%HOSTCMD(ZOSHC)
133 Q
134DF(X) ;Dir frmt
135 Q:X=""
136 S X=$TR(X,"\","/")
137 I $E(X,$L(X))'="/" S X=X_"/"
138 Q
139STATUS() ;Eof flag
140 Q $ZC
141QL(X) ;Qlfrs
142 Q:X=""
143 S:$E(X)'="-" X="-"_X
144 Q
145FL(X) ;Fl len
146 N ZOSHP1,ZOSHP2
147 S ZOSHP1=$P(X,"."),ZOSHP2=$P(X,".",2)
148 I $L(ZOSHP1)>14 S X=4 Q
149 I $L(ZOSHP2)>8 S X=4 Q
150 Q
151 ;
152FTG(%ZISHX1,%ZISHX2,%ZISHX3,%ZISHX4,%ZISHX5) ;Unload contents of host file into global
153 ;p1=hostf file directory
154 ;p2=host file name
155 ;p3= NOW $NAME REFERENCE INCLUDING STARTING SUBSCRIPT
156 ;p4=INCREMENT SUBSCRIPT
157 ;p5=Overflow subscript, defaults to "OVF"
158 N %ZISH,%ZISH1,%ZISHI,%ZISHL,%ZISHLGR,%ZISHS,ZISHIO,%ZISHOVL,%ZISHX,ZISHY
159 S %ZISHLGR=$$LGR^%ZOSV ;if possible, save off last global reference
160 S %ZISHOVL=$G(%ZISHOVL,"OVF")
161 S %ZISHI=$$QS^XLFUTL(%ZISHX3,%ZISHX4)
162 S %ZISHL=$$QL^XLFUTL(%ZISHX3)
163 I %ZISHX4=(%ZISHL+1),%ZISHI="" S %ZISHI=1
164 S %ZISH1=$NA(@%ZISHX3,%ZISHX4-1)
165 F %ZISH=%ZISHX4+1:1:%ZISHL S %ZISHS(%ZISH)=$$QS^XLFUTL(%ZISHX3,%ZISH)
166 D OPEN^%ZISH("",%ZISHX1,%ZISHX2,"R")
167 S %ZISHX="",%ZPZB="",%ZPL="",%OVLCNT=0,%CONT=0,%ZISHNREC=1
168 U IO F D READNXT(.%XX) Q:$$STATUS&'$L(%XX) D ;U 0 W !,"%ZB="_%ZB,!,"%ZPZB+%ZL="_(%ZPZB+%ZL),!,"%ZPZB="_%ZPZB_" %ZL="_%ZL U IO S %ZISHNREC=$S(%ZB'=(%ZPZB+%ZL):1,1:0) S:%ZISHNREC %ZISHI=%ZISHI+1 S %ZPZB=$ZB,%ZPL=%ZL
169 .I %ZISHNREC D
170 ..U 0 W !,"NEWRECORD" U IO
171 ..S %ZISHX=%XX
172 ..S %ZISH2=$NA(@%ZISH1@(%ZISHI))
173 ..S %ZISH=%ZISH+1
174 ..F %ZISH=%ZISHX4+1:1:%ZISHL S %ZISH2=$NA(@%ZISH2@(%ZISHS(%ZISH)))
175 ..S @%ZISH2=$E(%ZISHX,1,255)
176 ..S %OVLCNT=0,%CONT=0
177 ..Q:%ZL'>255
178 ..D LOOP
179 .E D
180 ..U 0 W !,"CONTINUATION RECORD" U IO
181 ..S %ZL2=$L(%ZISHX),%ZISHX=%ZISHX_$E(%XX,1,255-%ZL2)
182 ..D SETOVL
183 ..S %XX=$E(%XX,256-%ZL2,$L(%XX))
184 ..S %ZISHX=%XX
185 ..D:%ZISHX]"" SETOVL
186 ..I $L(%ZISHX)>255 D LOOP
187 .U 0 W !,"%ZB="_%ZB,!,"%ZPZB+%ZL="_(%ZPZB+%ZL),!,"%ZPZB="_%ZPZB_" %ZL="_%ZL U IO
188 .S %ZISHNREC=$S(%ZB'=(%ZPZB+%ZL):1,1:0)
189 .I %ZISHNREC D
190 ..S %ZISHI=%ZISHI+1 ;B:%ZISHI=2
191 .S %ZPZB=$ZB,%ZPL=%ZL
192 ;I %ZISHX]"",%ZISHNREC D SETOVL
193EOF2 C IO K IO(1,IO)
194 I $G(%ZISHLGR)]"",$D(@%ZISHLGR) ;restore last global reference.
195 Q 1
196LOOP S %CONT=1 F Q:$L(%ZISHX)'>255 D
197 .S %ZISHX=$E(%ZISHX,256,$L(%ZISHX))
198 .D SETOVL:$L(%ZISHX)>255
199 Q
200NEXTLUP F Q:%ZA=%ZL D
201 .D READNXT(.%XX) Q:$$STATUS
202 .S %ZL2=$L(%ZISHX),%ZISHX=%ZISHX_$E(%XX,1,255-%L2)
203 .D SETOVL
204 .S %XX=$E(%XX,256-%L2,$L(%XX))
205 .I $L(%XX)>255 S %ZISHX=%XX D LOOP
206 .E S %ZISHX=%XX D SETOVL
207 Q
208READNXT(%XX) ;
209 U IO R %XX Q:$$STATUS S %ZA=$ZA,%ZB=$ZB,%ZL=$L(%XX)
210 Q
211SETOVL ;
212 S %OVLCNT=%OVLCNT+1
213 S @$NA(@%ZISH1@(%ZISHI))@(%ZISHOVL,%OVLCNT)=$E(%ZISHX,1,255)
214 Q
215 Q 1
216GTF(%ZISHX1,%ZISHX2,%ZISHX3,%ZISHX4) ;Load contents of global to host file.
217 ;p1=$NAME of global reference
218 ;p2=incrementing subscript
219 ;p3=host file directory
220 ;p4=host file name
221 ;
222 N %ZISHLGR,%ZISHY
223 S %ZISHLGR=$$LGR^%ZOSV ;if possible, save off last global reference
224 S %ZISHY=$$MGTF(%ZISHX1,%ZISHX2,%ZISHX3,%ZISHX4,"W")
225 Q %ZISHY
226GATF(%ZISHX1,%ZISHX2,%ZISHX3,%ZISHX4) ;Load contents of global to host file.
227 ;p1=$NAME of global reference
228 ;p2=incrementing subscript
229 ;p3=host file directory
230 ;p4=host file name
231 N %ZISHLGR,%ZISHY
232 S %ZISHLGR=$$LGR^%ZOSV ;if possible, save off last global reference
233 S %ZISY=$$MGTF(%ZISHX1,%ZISHX2,%ZISHX3,%ZISHX4,"A")
234 I $G(%ZISHLGR)]"",$D(@%ZISHLGR)
235 Q %ZISHY
236 ;
237MGTF(%ZISHX1,%ZISHX2,%ZISHX3,%ZISHX4,%ZISHX5) ;Load contents of global to host file.
238 ;p1=$NAME of global reference
239 ;p2=incrementing subscript
240 ;p3=host file directory
241 ;p4=host file name
242 ;p5=access mode
243 N %ZISH,%ZISH1,%ZISHI,%ZISHL,%ZISHS,%ZISHIO,%ZISHX,%ZISHY
244 S %I=$$QS^XLFUTL(%ZISHX1,%ZISHX2)
245 S %L=$$QL^XLFUTL(%ZISHX1)
246 S %1=$NA(@%ZISHX1,%ZISHX2-1)
247 F %ZISH=%ZISHX2+1:1:%ZISHL S %ZISHS(%ZISH)=$$QS^XLFUTL(%ZISHX1,%ZISH)
248 D OPEN^%ZISH("",%ZISHX3,%ZISHX4,%ZISHX5)
249 S %ZISHX="EOF3^%ZISH"
250 F D Q:'($D(@%ZISH2)#2) S %ZISHX=@%ZISH2,%ZISHI=%ZISHI+1 U IO W %ZISHX,!
251 .S %ZISH2=$NA(@%ZISH1@(%ZISHI))
252 .F %ZISH=%ZISHX2+1:1:%ZISHL S %ZISH2=$NA(@%ZISH2@(%ZISHS(%ZISH)))
253 ;C %ZISHIO
254 D CLOSE^%ZISH("")
255 Q 1
256 Q
Note: See TracBrowser for help on using the repository browser.