 |
» |
|
 |
|
 |

Copyright (c) Digital Equipment Corporation 1991. All rights reserved
LAYERED PRODUCT: VAX PLI, V3.4 OP/SYS: VMS, 5.4
SOURCE: Digital Customer Support Center
OVERVIEW:
This article contains a command procedure that demonstrates how to
install a common area that can be shared among processes.
*** CAUTION ***
This sample program has been tested using VAX PLI V3.4 on VMS 5.4.
However, we cannot guarantee its effectiveness because of the possibility
of error in transmitting or implementing it. It is meant to be used as a
template for writing your own program and it may require modification for
use on your system.
PROGRAM NOTES:
In the command procedure, a common is created in ARRAY.PLI. It is
linked as SHARED, moved to SYS$SHARE and then installed. The two programs,
TEST and TEST2, load and print the array1 variable in ARRAY respectively.
The .exe and .obj files are deleted when done, and the common is deinstalled
and deleted from SYS$SHARE.
Note: CMKRNL and SYSPRV privileges are required to run this example.
PROGRAM:
Extract the following into a .COM file and invoke with @command_file_name:
$! CREATE THE ARRAY THAT WILL BE INSTALLED AND SHARED
$ CREATE ARRAY.PLI
array: proc;
dcl array1 (50) fixed bin(31) external;
end array;
$ PLI ARRAY.PLI
$ LINK/SHARE ARRAY.OBJ
$! COMPILE AND LINK THE 2 PROGRAMS THAT WILL ACCESS THE ARRAY
$ CREATE TEST.PLI
test: proc options (main);
dcl array1(50) fixed bin(31) external;
dcl i fixed bin(31);
do i = 1 to 50;
array1 (i) = i * 2;
end;
end;
$ CREATE TEST2.PLI
test2: proc options (main) ;
dcl array1(50) fixed bin(31) external;
dcl i fixed bin(31);
do i = 1 to 50;
put list (array1(i));
end;
end;
$ PLI TEST.PLI
$ PLI TEST2.PLI
$ CREATE OPTFILE.OPT
SYS$SHARE:ARRAY/SHARE
$! INSTALL THE ARRAY AS A "COMMON"
$ SET PROCESS/PRIV=(CMKRNL,SYSPRV)
$ COPY ARRAY.EXE SYS$SHARE:ARRAY.EXE
$ INSTALL ADD/OPEN/HEADER/SHARE/WRITE SYS$SHARE:ARRAY
$ LINK TEST,OPTFILE/OPT
$ LINK TEST2,OPTFILE/OPT
$! RUN THE 2 PROGRAMS THAT WILL INITIALIZE AND PRINT THE ARRAY
$ RUN TEST
$ RUN TEST2
$! CLEANUP
$ DEL TEST.OBJ;
$ DEL TEST2.OBJ;
$ DEL TEST.EXE;
$ DEL TEST2.EXE;
$ DEL ARRAY.OBJ;
$ DEL ARRAY.EXE;
$ INSTALL DELETE SYS$SHARE:ARRAY
$ DEL SYS$SHARE:ARRAY.EXE;
$ SET PROCESS/PRIV=(NOCMKRNL,NOSYSPRV)
|
buy online or call 1.800.AT.COMPAQ
|
|