From: Gareth V. Williams [graff@cfa0.cfa.harvard.edu] Sent: Wednesday, November 12, 2003 12:58 PM To: Info-VAX@Mvb.Saic.Com Subject: Mail Utility Routines problem How does one set the new mail count? I have a number of programs that manipulate mail files for sundry purposes, and I've never managed to set the new mail count once I've finished moving/deleting mail messages. This means that when I go into MAIL in an account that runs one of these programs, I have to READ/NEW to reset the counter. I'd obviously like to get this working automatically. Relevant bits of code from one of these programs (running on V7.2-1) looks like this (with two lines of debugging output): ! Declarations (allow up to 10 input and output list items) STRUCTURE/ItemList/ INTEGER*2 BLen INTEGER*2 Code INTEGER :: BufAdr INTEGER :: RetLenAdr END STRUCTURE RECORD/ItemList/InList(10),OutList(10),NullList NullList.Code = 0 NullList.BLen = 0 NullList.BufAdr = 0 NullList.RetLenAdr = 0 ! Begin USER context UserContext = 0 Status = MAIL$User_Begin(UserContext,NullList,NullList) short new_messages = 0; /* need NUMNEWMESS to be 2 bytes */ IF (NUMMESS .NE. NUMNEWMESS) THEN PRINT *,"Setting count of new messages",NUMNEWMESS,USERNAME InList(1).Code = MAIL$_USER_USERNAME InList(1).BLen = LEN_TRIM(USERNAME) InList(1).BufAdr = %LOC(USERNAME) InList(1).RetLenAdr = 0 InList(2).Code = MAIL$_USER_SET_NEW_MESSAGES InList(2).BLen = 2 /* was 4, apparently wrong for 2 byte int */ InList(2).BufAdr = %LOC(NUMNEWMESS) InList(2).RetLenAdr = 0 InList(3) = NullList Status = MAIL$User_Set_Info(UserContext,InList,NullList) PRINT *,"Set count of new messages" ENDIF Attempting to run the program produces: $ antispam Cleaning MAIL file of SPAM... Number of new messages = 1 Number of probable SPAM messages = 1 Number of possible SPAM messages = 0 Number of messages left in NEWMAIL = 0 Setting count of new messages 0 TEMP %MAIL-E-INVITMLEN, invalid item length %TRACE-E-TRACEBACK, symbolic stack dump follows image module routine line rel PC abs PC MAILSHR 0 000000000004CD80 000000007B6A4D80 MAILSHR 0 000000000003AD48 000000007B692D48 ANTISPAM_EV67 ANTISPAM ANTISPAM 1123 00000000000020AC 00000000000320AC 0 FFFFFFFF8C4173F4 FFFFFFFF8C4173F4 Set count of new messages You have 1 new message. MAIL> dir/new %MAIL-W-NONEWMAIL, no new messages The problem seems to be the input items declaring the new value of the new mail count. If I comment out those lines and set InList(2) = NullList, I don't get an error message (but of course, the new mail count doesn't then change). The error message appears if I remove the InList(1), make the declaration of the new mail count InList(1) and set InList(2) = NullList, using the default of modifying the user record associated with the calling process. Comparing the above code to the documentation on MAIL$USER_SET_INFO ("Mail Utility Routine MAIL-106 to MAIL-110), I don't see where the problem is. In particular, I don't see what the "invalid item length" error is referring to. A search of the DejaNews archive and a Google search turned up nothing, so I'm probably missing something bleedin' obvious. Any pointers would be appreciated. -- ------------------------------------------------------------------------ Gareth V. Williams, MS 18, 60 Garden Street, Cambridge, MA 02138, U.S.A. Associate Director, IAU Minor Planet Center gwilliams@cfa.harvard.edu http://cfa-www.harvard.edu/iau/mpc.html OpenVMS & RISC OS: refined choices in operating systems