GDSX Manual

Using Pseudo Procedures in a NonStop TS/MP
Environment
Extended General Device Support (GDSX) Manual134303
D-7
USAMPLE1 Listing
93. Int Evt := 0;
94.
96. !===========================================================================
97. ! Initialization procedure
98. !===========================================================================
99. SubProc Initialize^Device^Handler;
100. Begin
101.
102. ! reserve all the buffers we need
103. @RCV^Buf := GetExtPool(11,32); ! from message pool
104. If @RCV^Buf = 0D Then
105. Call Debug;
106.
107. @Term^Buf := GetExtPool(11,32); ! from message pool
108. If @Term^Buf = 0D Then
109. Call Debug;
110.
111. @Work^Buf := GetExtPool(10,32); ! from buffer pool
112. If @Work^Buf = 0D Then
113. Call Debug;
114.
115. While 1 Do Begin
116. -- Read messages from $RECEIVE, until we receive our initialization
messge
117. Call ^Readupdatex(Dolr^Rcv,Rcv^Buf,64);
118.
119. Evt := Wait^Event ((Disp^Imsg + Disp^Stop), -1D);
120.
121. Case Evt of Begin
122. E^Imsg -> ! from $RECEIVE
123. Begin
124. -- let's get the address of the IOCB for the message just
completed
125. @Rcv^Iocb := ^Listen (1,0,0);
126. -- get the new bufferaddress
127. @Work^Buf := Rcv^Iocb.BufaddrX;
128. -- move the buffer
129. If Work^Buf[7] = ["Initialization"] Then Begin
130. -- If we have the init. message, we can exit this loop
131. -- write the first buffer and wait for the first message
132. Term^Buf ':=' "Enter your text: xnnnkkkkkkkkkkk.... " &
133. Term^Buf[18] for 12;
134. Call ^WriteReadX(Term^File^Num, Term^Buf, 50, 64);
135. -- return to the main-loop
136. Return;
137. End
138. Else
139. -- reply to $RECEIVE, but not to the init. message
140. -- (this is done in the main loop)
141. Call ^Replyx();
142. End;
143. E^Stop -> ! task is stopping
144. Call Stop^Task;
145. End;
146. End; ! of While
147.
148. End;
149.
151. !===========================================================================
152. Int SubProc Check^Buffer;
153. !===========================================================================
154. ! we return the value 0, when we detected an error
155. ! we return the value 1, when the buffer is OK
156. !===========================================================================
157. Begin
158.
159. Int S^Error;
160.
161. S^Error := String_Upshift_ (S^Term^Buf[0]:1,S^Term^Buf[0]:1);
162. If S^Error Or
163. S^Term^Buf[0] <> ["W"] And
164. S^Term^Buf[0] <> ["D"] Then Begin
165. Term^Buf ':=' "wrong function code (x) (must be 'd' or 'w') " &