From: CSBVAX::MRGATE!@KL.SRI.Com,@wiscvm.wisc.edu:LANGFORD@VCUVAX.BITNET@SMTP 5-NOV-1987 12:08 To: EVERHART Subj: RE: Signalling VMS conditions from Pascal programs Received: from wiscvm.wisc.edu by KL.SRI.COM with TCP; Wed 4 Nov 87 12:55:13-PST Received: from VCUVAX.BITNET by wiscvm.wisc.edu ; Wed, 04 Nov 87 14:55:00 CDT Date: Wed, 4 Nov 87 15:53 EST From: (Bob Langford) Subject: RE: Signalling VMS conditions from Pascal programs To: info-vax@kl.sri.com X-Original-To: info-vax@kl.sri.com, LANGFORD In response to: >FROM: Bill Costa, University Computing >Subject: TIP ON: Using the message facility with Pascal > > I wanted to use the Message Utility with my VAX Pascal programs. > Unfortunately there does not appear to be any way of declaring external > constants in VAX Pascal. This means that you would have to hand-code > the "condition codes" values found in the Message Utility listing of > your message file into your Pascal program. Uck! However, I think I've > worked out what I think is a better way. The trick is to declare some > [EXTERNAL] variables with the same name as the condition code symbols > that you defined in your message file. These variables will contain > nothing (and thus waste a little space), but they will be recognized by > the linker as being the same as the symbols defined in the message OBJ > file. > > **NOW** - I have a question for the VMS/VAX Pascal *gurus* out there. > Could you give me a hint (in other words show me) how to declare > LIB$SIGNAL in VAX Pascal so I can pass FAO arguments? I've been doing this for some time, and include the following Pascal example (heavily chopped to pieces to leave just the good stuff) to show how I do it. Hope this helps! Bob Langford, Medical College of Virginia / Virginia Commonwealth Univ. LANGFORD @ VCUVAX (Bitnet) --------------------------- { Pascal fragments to show how I signal errors from Pascal programs. } [inherit('sys$library:starlet', { System services and RMS } 'sys$library:rtl')] { RTL routines including LIB$SIGNAL (a homegrown file) } program DETAB (input, output); var { Error messages. } DETAB__ERROPEINP, DETAB__ERROPEOUT : [external, value] integer; inStat : integer; {+++ The [external, value] attributes are new in Pascal, but they do exactly what you want/need in this case: tell the compiler that this is a global symbol defined in another module, whose address should be used as an integer. It could also be defined as UNSIGNED, if you declare LIB$SIGNAL that way, but all the routines in STARLET.PAS return INTEGERs (when they should give UNSIGNED, according to the System Services manual). ---} begin lib$signal (DETAB__ERROPEINP, 1, %stdescr FileSpec, inStat); {+++ This call actually signals two condition codes: DETAB__ERROPEINP and the code in "inStat" (in this case, an RMS condition code). The DETAB__ERROPEINP signal has 1 argument, "FileSpec", which is a varying length string (varying [100] of char). ---} end. { main } --------------------------- Here's the declaration of LIB$SIGNAL used above (from SYS$LIBRARY:RTL.PAS, a file we had to write ourselves): [EXTERNAL, ASYNCHRONOUS] function LIB$SIGNAL ( %immed cond : [readonly] integer := %immed 1; %immed params : [readonly,list,unsafe] integer := %immed 0 ) : integer; external; --------------------------- Here's the Message utility input file: .title DETAB program error messages .ident 'V 1.0' .facility DETAB, 1000 /prefix=DETAB__ .severity ERROR ErrOpeInp "Error opening input file, `!AS'"/fao=1 ErrOpeOut "Error opening output file, `!AS'"/fao=1 .end --------------------------- Here's how I compile/link it all: $ pascal mainpgm.pas $ message error_codes.msg $ link/notraceback mainpgm.obj,error_codes.obj (naturally, system-wide condition values are automatically found by the linker, and no .OBJ file need be given for them.)