In article <19@mixcom.UUCP>, oovvoo@mixcom.UUCP (Michael W. Shawaluk) writes: > I am developing a program in C, which outputs a number of error and/or > informational messages via LIB$SIGNAL and the MESSAGE facility (i.e., I have > a .MSG file which I "compile" with the MESSAGE command, and I "globalref" > all of the symbols which I want to reference in the messages). This > technique works fine, except that there are a couple of cases in which it > would be handy to output these messages without the trailing CR's that > LIB$SIGNAL seems to insist on putting there (one example is a confirmational > prompt, much like the "are you sure?" message that DELETE/CONFIRM gives). > So my question is, is there an easy way to do this, and still have the > benefit of defining the message text via the .MSG file? I must confess to > not being really up on all of the various FAO directives and options, and I > apologize in advance if I'm missing something simple. > > Thanks in advance; feel free to email and/or post any suitable suggestions > or comments. > > - Mike You can use the SYS$GETMSG system service routine to get the text of the message, and then use SYS$FAO or SYS$FAOL to translate any of the parameters. This isn't too difficult a proposition. In fact, here are two routines that I use (one is in VAXC and the other in VAX MACRO) to use the message facility from VAXC. I apoligize if this is too long for some of you. =============================================================================== CUT HERE =============================================================================== /****************************************************************************** * * File: Lexicals.H * Author: David R. Potter * Creation Date: 12-Aug-1987 * ****************************************************************************** * * Description: * * This file contains definitions for use with the f_message function. * ******************************************************************************/ /*** Constants for use with f_message(): ***/ #define F_MSGTEXT 0x01 /* Include text of message. */ #define F_MSGID 0x02 /* Include message identifier. */ #define F_MSGSEV 0x04 /* Include severity indicator. */ #define F_MSGFAC 0x08 /* Include facility name. */ extern int f_message( long, char *, long, unsigned long ); extern int f_fao( char *, char *, uword, ... ); =============================================================================== CUT HERE =============================================================================== /****************************************************************************** * * File: F_Message.C * Author: David R. Potter * Creation Date: 12-Aug-1987 * ****************************************************************************** * * Description: * * This function will operate like the DCL F$MESSAGE lexical function. * This function will obtain the message associated with an error code * returned by system services, RTL functions, RMS functions, etc. * * Inputs: * lErrCode The error code whose message is to be returned. * pszMsg The address of a string in which to place the message. * lBufSize The size of pszMsg. * ulMsgFlags Code indicating which parts of the message are to be * returned. The following mask values are acceptable: * F_MSGTEXT = Return the message text. * F_MSGID = Return the message identifier. * F_MSGSEV = Return the message severity indicator. * F_MSGFAC = Return the message facility name. * If 0 is specified, the process default flags will be * used. * * Outputs: * pszMsg The desired message. * * Returns: * Sts The status from sys$getmsg. * ******************************************************************************/ #include #include #include #include "f_message.h" /****************************************************************************** * * f_message Get the Message from SYS$GETMSG. * ******************************************************************************/ int f_message ( long lErrCode , char *pszMsg , long lBufSize , unsigned long ulMsgFlags ) { /* VARIABLES */ int Sts; /* Status from function calls.*/ word wMsgLen; /* Returned length of message.*/ char abMsgStuff[4]; /* Output information from */ * SYS$Getmsg(). */ #pragma nostandard $DESCRIPTOR( dMsg, pszMsg ); /* Message buffer descriptor. */ #pragma standard /*** Set descriptor for getmsg call. *** *** Make sure buffer is big enough. ***/ if ( lBufSize > 1 ) dMsg.dsc$w_length = lBufSize - 1; else return( SS$_BUFFEROVF ); /*** Get the message. ***/ Sts = SYS$Getmsg ( lErrCode /* Message ID. */ , &wMsgLen /* Output length variable. */ , &dMsg /* Output buffer descriptor.*/ , ulMsgFlags /* Message component flags. */ , abMsgStuff /* Optional info address. */ ); /*** Null terminate the message if it was found. ***/ if ( ERROR( Sts ) ) pszMsg[0] = '\0'; else { pszMsg[wMsgLen] = '\0'; /* Null terminate message. */ /*** If first character is not a %, only the message *** *** text was returned. Capitalize the first character. ***/ if ( pszMsg[0] != '%' ) pszMsg[0] = _toupper( pszMsg[0] ); } /* else: message was returned */ /*** Return the status. ***/ return( Sts ); } /*** f_message() ***/ =============================================================================== CUT HERE =============================================================================== .TITLE F_FAO Function Callable From C .IDENT "V1.2.0" ;------------------------------------------------------------------------------ ; ; File: F_Fao.Mar ; Author: David R. Potter ; Creation Date: 21-Sep-1990 ; ;------------------------------------------------------------------------------ ; ; Description: ; ; This function implements the FAO system routine from a C program using ; null-terminated strings. ; ; Call: ; int = F_Fao( pszControl, pszOutStr, uwOutLen, ... ); ; ; Inputs: ; 4(ap) The address of a null-terminated string ; containing the FAO control string. ; 8(ap) The address of a string into which to ; write the result as a null-terminated ; string. ; 12(ap) A word specifying the maximum length of ; the output string. The value used in ; the call to FAO will be one less than ; this value to allow for the null- ; termination. ; 16(ap) et. al. The FAO parameters. ; ; Outputs: ; The output string from FAO null- ; terminated. If an error occurs, the ; first character will be null. ; ; Return: ; Any condition values from FAO. ; ;------------------------------------------------------------------------------ ; ; f_fao C Interface To SYS$Fao. ; ;------------------------------------------------------------------------------ .PSECT F_FAO, PIC, CON, REL, GBL, SHR, EXE, RD, NOWRT, LONG .ENTRY f_fao, ^M ; Parameters: pszControl = 4 pszOutStr = 8 uwMaxLen = 12 ; Set aside stack space for local variables: dControl = -8 ; Desriptor for the control string. dOutStr = -16 ; Descriptor for the output string. uwOutLen = -18 ; Length of the output string from FAO. subl #20, sp ; Initialize the output string to be empty. movb #0, @pszOutStr(AP) ; Initialize the output string ; to empty. ; Find the length of the control string. pushl pszControl(AP) ; Push the string whose length ; is to be obtained. calls #1, g^STRLEN ; Get its length. ; Setup the descriptors. movw R0, dControl(FP) ; Set the length of the ; descriptor. clrw (FP) ; Clear out the type and class. movl pszControl(AP), (FP); Set the address of the ; control string. subw3 #1,uwMaxLen(AP), dOutStr(FP) ; Set the length of the ; descriptor. clrw (FP) ; Clear out the type and class. movl pszOutStr(AP), (FP) ; Set the address of the output ; string. ; Push the FAO parameters onto the stack first. rotl #2, (AP), R2 ; Get the offset to the last ; parameter. addl3 AP, R2, R3 ; Get the actual address of the ; parameter. tstl (R3)+ ; Point past the last one. 10$: cmpl R2, #uwMaxLen ; Are there any more FAO ; parameters? beql 20$ ; Branch if not. pushl -(R3) ; Push the parameter onto the ; stack for the call to FAO. subl #4, R2 ; Decrement the current offset. brb 10$ ; Get the next parameter. ; Call FAO. The AP register happens to contain the number of parameters ; required for the call to FAO. 20$: pushaq dOutStr(FP) ; Push the address of the ; output string descriptor. pushaw uwOutLen(FP) ; Push the address of the ; output length word. pushaq dControl(FP) ; Push the address of the ; control string descriptor. calls (AP), g^SYS$FAO ; Call FAO. blbc R0, 30$ ; Branch if an error occurred. ; Null terminate the output string. movw uwOutLen(FP), R2 ; Get the offset to the end of ; the output string. movl pszOutStr(AP),R3 ; Get the address of the output ; string buffer. clrb (R3)[R2] ; Null-terminate the string. 30$: ret ; Return to the caller. ;------------------------------------------------------------------------------ .END =============================================================================== CUT HERE =============================================================================== -- David Potter Voice: (714) 970-1515 Data Processing Design UUCP: {lawnet,zardoz,dhw68k}!dpdvax!potter Anaheim, CA Internet: potter@dpdvax.uucp /* ---------- */