GDSX Manual

Using Pseudo Procedures in a NonStop TS/MP
Environment
Extended General Device Support (GDSX) Manual134303
D-8
USAMPLE1 Listing
166. Term^Buf[22] For 18 Bytes;
167. Return 0;
168. End;
169.
170. If Not $Numeric(S^Term^Buf[1]) Or
171. Not $Numeric(S^Term^Buf[2]) Or
172. Not $Numeric(S^Term^Buf[3]) Then Begin
173. Term^Buf ':=' "loop-counter (nnn) is not numeric " &
174. Term^Buf[17] For 28 Bytes;
175. Return 0;
176. End;
177.
178. -- everything is OK
179. Return 1;
180.
181. End;
185. !===========================================================================
186. ! DEVICE^HANDLER Procedure MAIN ENTRY POINT Begins here
187. !===========================================================================
188.
189. ! Find out our own DCB- and TCB-address
190. @My^Dcb := Dcbtbl[Internal^Term^No];
191. @My^Tcb := My^Dcb.Tcbaddr;
192.
193. -- Do the initialization - wait for buffer 'Initialization'
194. Call Initialize^Device^Handler;
195.
196. -- Do the Main-Loop
197. While 1 Do Begin
198.
199. Evt := Wait^Event ((Disp^Imsg + Disp^Ioc + Disp^Stop), -1D);
200.
201. Case Evt of Begin
202. E^Imsg -> ! From $Rcv
203. Begin
204. -- let's get the address of the IOCB for the message just
completed
205. @Rcv^Iocb := ^Listen (1,0,0);
206. -- get the new address of the new buffer
207. @Work^Buf := Rcv^Iocb.BufaddrX;
208. -- move the buffer
209. Term^Buf ':=' "Rep: " & Work^Buf[1] For
210. (Rcv^Iocb.Iocnt-2) Bytes;
211. -- write the buffer to our device
212. Call ^WriteReadX(Term^File^Num, Term^Buf, 50, 62);
213. End;
214.
215. E^Ioc -> ! from our device
216. Begin
217. -- let's get the address of the IOCB for the message just
completed
218. @Term^Iocb := ^Listen (0,-1,0);
219. -- get the new address of the new buffer
220. @Work^Buf := Term^Iocb.BufaddrX;
221. -- clear the buffer, that we send to the IDS requester
222. RCV^Buf ':=' " " & RCV^Buf for 31;
223. -- move the buffer that we received from our device
224. RCV^Buf ':=' 0 & Work^Buf For Term^Iocb.Iocnt Bytes;
225. If Check^Buffer Then Begin
226. -- Buffer passed our checks
227. -- send the buffer that we just received to the IDS requester
228. Call ^Replyx(S^RCV^Buf, 64, ,Rcv^Iocb.MsgTag);
229. -- wait for the reply from the IDS requester
230. Call ^Readupdatex(Dolr^Rcv, RCV^Buf, 64);
231. End
232. Else Begin
233. -- buffer did not pass our checks
234. -- write the errorsmessage and let the user retry
235. Call ^WriteReadX(Term^File^Num, Term^Buf, 50, 62);
236. End;
237. End;
238.
239. E^Stop -> -- task is stopping