<<< NODE::DISK$PAGESWAPPER:[000000]IO.NOTE;3 >>> -< Submissions to the Pageswapper INPUT/OUTPUT Column >- ================================================================================ Note 685.1 Need unread Mail count 1 of 1 NODE::US170993 "Mark Oakley" 196 lines 5-JUL-1987 23:04 -< Program to get unread mail count >- -------------------------------------------------------------------------------- Listed below is a program to read the unread mail count for a user. It requires access to VMSMAIL.DAT, so it will probably have to be installed with SYSPRV. I "copied" the program from the fiche, translating their BLISS to my Macro. Users at our site wanted to check their unread mail count in their "LOGOUT.COM", without having to run MAIL. Feel free to call, write, or reply (to this node) if you have any questions or problems. I plan to submit this program to the VAX SIG tapes. Mark Oakley Battelle Memorial Institute 505 King Ave. Columbus, Ohio 43201-2693 (614) 424-7154 ************************************************************** MAILCNT is a utility that reads and prints the number of unread mail messages for a user. ************************************************************** $ MACRO/LIST MAILCNT $ LINK/NOTRACE MAILCNT $ EXIT ************************************************************** .TITLE MAILCNT Return Count of New Mail Messages in VMS Mail ;++ ; ; Title: ; MAILCNT.MAR - Return new mail count. ; ; Version: ; 1.0 ; ; Facility: ; Local VMS mail utility. ; ; Abstract: ; This program reads VMSMAIL.DAT for a particular user; and ; returns the new mail count. ; ; Environment: ; Requires read access to VMSMAIL.DAT ; ; Author: ; Mark Oakley Battelle Memorial Institute 12-Jun-1987 ; ; Modified: ; ; 14-Jun-1987 Mark Oakley Store new mail count in a local ; symbol called BAT$NEW_MAIL_COUNT. ; ; 16-Jun-1987 Mark Oakley Don't output any mail message. ; ;-- .SBTTL Symbols, macros, data .PSECT MAILCNT_DATA RD,WRT,NOEXE,SHR,LONG,PIC $JPIDEF $FABDEF $RABDEF $NAMDEF VMD_K_USERNAME = 31 ; ; Macro to handle return codes. ; .MACRO ON_ERR THERE,?HERE BLBS R0,HERE BRW THERE HERE: .ENDM ON_ERR KEY_BUF: ; Key will be username. .BLKB 12 KEY_BUF_LEN = . - KEY_BUF .BLKB VMD_K_USERNAME-12 KEY_LEN: ; Username length. .BLKL 1 JPI_ITMLST: ; Item list to retrieve username. .WORD KEY_BUF_LEN .WORD JPI$_USERNAME .ADDRESS KEY_BUF .ADDRESS KEY_LEN .LONG 0 .ALIGN LONG MAIL_FAB: ; RMS data structure to open VMSMAIL $FAB FNM=,- ; and read a record. FAC=GET,- SHR= MAIL_RAB: $RAB FAB=MAIL_FAB,- RAC=KEY,- ROP=,- KRF=0,- KSZ=VMD_K_USERNAME,- KBF=KEY_BUF,- RBF=MAIL_REC,- USZ=MAIL_REC_LEN,- UBF=MAIL_REC MAIL_REC: .BLKB KEY_BUF_LEN .BLKB 3 .BLKB NAM$C_MAXRSS MAIL_REC_LEN = . - MAIL_REC NEW_MAIL_COUNT: .BLKL 1 FORMAT: .ASCID /You have !UL new mail message(s)./ OUTBUF: .BLKB 50 OUTBUF_SIZ = . - OUTBUF OUTBUF_DESC: .LONG OUTBUF_SIZ .ADDRESS OUTBUF OUTBUF_LEN: .BLKL 0 SYMBOL_NAME: .ASCID /BAT$NEW_MAIL_COUNT/ SYMBOL_FORMAT: .ASCID /!UL/ SYMBOL_VALUE: .ASCID / / .SBTTL Code .PSECT MAILCNT_CODE RD,NOWRT,EXE,LONG,SHR,PIC .ENTRY MAILCNT,^M MOVC5 #0,.,#^A/ /,- ; Blank-fill key buffer #VMD_K_USERNAME,KEY_BUF $GETJPI_S - ; Get our username. ITMLST=JPI_ITMLST ON_ERR EXIT $OPEN FAB=MAIL_FAB ; Open VMSMAIL.DAT. ON_ERR EXIT $CONNECT - RAB=MAIL_RAB ON_ERR EXIT $GET MAIL_RAB ; Read our mail record - it ON_ERR EXIT ; contains the new mail count. $CLOSE FAB=MAIL_FAB ON_ERR EXIT MOVW MAIL_REC+VMD_K_USERNAME+2,- NEW_MAIL_COUNT $FAO_S CTRSTR=FORMAT,- OUTLEN=OUTBUF_DESC,- OUTBUF=OUTBUF_DESC,- P1=NEW_MAIL_COUNT ON_ERR EXIT ; PUSHAL OUTBUF_DESC ; CALLS #1,G^LIB$PUT_OUTPUT ; ON_ERR EXIT $FAO_S CTRSTR=SYMBOL_FORMAT,- OUTLEN=SYMBOL_VALUE,- OUTBUF=SYMBOL_VALUE,- P1=NEW_MAIL_COUNT ON_ERR EXIT PUSHAL SYMBOL_VALUE PUSHAL SYMBOL_NAME CALLS #2,G^LIB$SET_SYMBOL ON_ERR EXIT EXIT: RET .END MAILCNT