;==File=================================================================;
; POGMAIL.DBL
;=======================================================================;
; Copyright 1999 by TAH Software Systems (TAH), Oklahoma City, Oklahoma ;
;									;
;	TAH provides this software under a license and may only be	;
;	used in accordance with the terms and conditions of such	;
;	license and with the inclusion of the above Copyright notice.	;
;==Function=============================================================;
;	po_get_mail	Read mail to record.
;==Changes==============================================================;
;=======================================================================;
.subroutine po_get_mail

	a_rec		,a	; OUT - record selected

.start nopage,nolist
.include "UTL:tools.def"
.include "UTS:dteut.def"

.include "UTS:utcomm.gbl"
.include "POS:pocomm.gbl"
.include "POS:pomail.rec"
.start nopage,list

.proc
	pomail = a_rec
	xcall db_find (pomail_chan,poa_key,0,'M',,,opcde)
	case opcde of
	  begincase
	  0: begin
		xcall db_next (pomail_chan,pomail,'F','M',,,opcde)
		unlock pomail_chan
		case opcde of
		  begincase
		  1: begin
		      xcall status (DTER_RNF)
		      clear pomail
		     end
		  2: begin
		      xcall status (DTER_LOK)
		      clear pomail
		     end
		  endcase
	     end
	  1: begin
	      xcall status (DTER_RNF)
	      clear pomail
	     end
	  2: begin
	      xcall status (DTER_LOK)
	      clear pomail
	     end
	  endcase

	a_rec = pomail
	xreturn	; to calling program
.end

