[comp.os.vms] Pascal declaration of Lib$Signal

ALLYN%CMS1@LLL-ICDC.ARPA (11/06/87)

	Bill Costa asked about a Pascal declaration of Lib$Signal which
uses the optional FAO parameters. I have modified his test programs to
demonstrate one method.

					Allyn Saroyan
					Lawrence Livermore National Laboratory
					(415) 423-2240

					My employer denies all knowledge of
					my existence and the existence of this
					note. Any damage done to any person
					or thing in the lifetime of the universe
					is strictly its own problem. Have a nice
					day.

....................... Cut between dotted lines and save ......................
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.01 01-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by ALLYN
$! on Thursday 5-NOV-1987 15:59:13.81
$!
$! It contains the following 2 files:
$! EXAMPLE.PAS EX_MESSAGES.MSG
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="EXAMPLE.PAS"
$ Check_Sum_is=1779239102
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
XPROGRAM Example;
X
X{
X  Shows how to use the Message Utility with Pascal without having to
X  hard-code the condition values generated by the message utility.
X  Additionally shows how to declare the Lib$Signal system service for
X  use of optional FAO arguments.
X
X  Original code by Bill Costa.
X}
X
XVAR
X     EX_Mess1   : [External,Volatile] Unsigned;
X     EX_Mess2   : [External,Volatile] Unsigned;
X     EX_Mess3   : [External,Volatile] Unsigned;
X     Ex_Mess4   : [External,Volatile] Unsigned;
X
X{-----------------------------------------------------------------------------}
X
X[Asynchronous]
XPROCEDURE Lib$Signal(
X
X             %Immed cond_Value : UNSIGNED              ;
X             %Immed count      : integer := 0          ;
X                    FAO_Pars   : [Unsafe,List,Class_S]
V                                 PACKED ARRAY [l..h:integer] OF char := %Immed 
X0
X                    );
X
XExternal;
X
X{-----------------------------------------------------------------------------}
X
X
XBEGIN { Example }
X
X   Lib$Signal( Iaddress( EX_Mess1 ) );
X   Lib$Signal( Iaddress( EX_Mess2 ) );
X   Lib$Signal( Iaddress( Ex_Mess4 ), 2, 'First', 'Second' );
X   Lib$Signal( Iaddress( EX_Mess3 ), 1,'oops');
X
XEND. { Example }
$ GoSub Convert_File
$ File_is="EX_MESSAGES.MSG"
$ Check_Sum_is=559772463
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X
X.TITLE          Example of using Message Facility with VAX/VMS Pascal V3.5
X.FACILITY       EX,1/PREFIX=EX_
X.IDENT          'Example'
X
X.SEVERITY       SUCCESS
X                Mess1           <Here is the first message.>
X
X.SEVERITY       INFORMATIONAL
X                Mess2           <And this is the second.>
X
X.SEVERITY       WARNING
X                Mess3           <Don't say '!AS' to me.>/fao=1
X
X.Severity`009Informational
X`009`009Mess4`009`009<!AS I would like to say '!AS'>/fao=2
X.END
X
$ GoSub Convert_File
$ Exit