Page 1 of 1
Pascal accessing shared image data
Posted: Thu Jul 22, 2021 11:01 am
by garyrevell
Hi,
I've got a shared image that contains system wide terminal data, the image is installed as:
$1$DGA100:<XXXXYYYY.0NN.SYSLIB>.EXE List head adr/siz/ref = 9D862830/52/26
TRM_DATA;9 Open Hdr Shared Lnkbl Wrt
And there's a [COMMON] record structure variable which stores the data and is defined as:
Terminals : [Common] terminal_data_rec;
What I'd like to do is be able to access the Terminals data via another program, so I can print the data out. So I've written a small Pascal report program and declared the following VARs
VAR
Ghost : terminal_file := ZERO;
Terminals : [Common] terminal_data_rec;
myterm : integer;
However, when I look at the Terminals data from my reporting program the data is empty/binary zero. So looks like I need to map the data but I'm not sure how to? Is there a Pascal function/procedure or so I need to use a system service to map it from the TRM_DATA.EXE?
Thanks in advance.
Gary
Re: Pascal accessing shared image data
Posted: Thu Jul 22, 2021 4:42 pm
by jreagan
Hi,
You'll have to call the $CRMPSC service yourself. Do you need help with an example? (I have lots of examples from over the years but not for this. I can whip up one tomorrow if nobody else jumps in first.)
Re: Pascal accessing shared image data
Posted: Fri Jul 23, 2021 4:05 am
by garyrevell
Hi,
Thanks very much for the offer, I'm not very familiar with VMS Pascal so an example would be very helpful.
Look forward to seeing how to do it!
Best regards
Gary
Re: Pascal accessing shared image data
Posted: Fri Jul 23, 2021 6:09 am
by martinv
IMHO, it should work without needing to use $CRMPSC. I'm assuming, of course, that
Terminals has been defined as a universal symbol in TRM_DATA.EXE (which is done when linking it).
What you need to do is link the example program against the shareable image, like
Code: Select all
$ LINK example.obj, sys$input/OPTION
$1$DGA100:<XXXXYYYY.0NN.SYSLIB>TRM_DATA.EXE /SHAREABLE
$
With that, your example program should be able to address the variable
Terminals from TRM_DATA.EXE.
Re: Pascal accessing shared image data
Posted: Fri Jul 23, 2021 8:49 am
by jreagan
I didn't consider if that data had a universal symbol.
Do you know how that TRM_DATA.EXE is linked? How it is referenced from other applications?
Re: Pascal accessing shared image data
Posted: Fri Jul 23, 2021 8:44 pm
by arne_v
I am not sure that I understand the problem completely.
And I have not worked with such writeable shareable images for 25 years.
But some random code and runs on VMS Alpha:
Code: Select all
$ type data.for
BLOCK DATA demo
INTEGER*4 a(256)
COMMON /demodata/a
DATA a /256*0/
END
$ for data
$ link data/share + sys$input/opt
SYMBOL_VECTOR=(demodata=PSECT)
PSECT_ATTR=demodata,SHR
$
$ install
remove disk2:[arne]data.exe
add disk2:[arne]data.exe /share/write
exit
$ define/sys/exe/nolog datashr disk2:[arne]data.exe
Code: Select all
$ type upd1.for
PROGRAM upd1
INTEGER*4 a(256)
COMMON /demodata/a
WRITE(*,*) a(1)
a(1) = a(1) + 1
END
$ for upd1
$ link upd1 + sys$input/opt
PSECT_ATTR=demodata,SHR
datashr/SHARE
$
$ run upd1
0
$ run upd1
1
$ run upd1
2
$ type upd2.pas
program upd2(input, output);
var
a : [common(demodata)] array [1..256] of integer;
begin
writeln(a[1]);
a[1] := a[1] + 1;
end.
$ pas upd2
$ link upd2 + sys$input/opt
PSECT_ATTR=demodata,SHR
datashr/SHARE
$
$ run upd2
3
$ run upd2
4
$ run upd2
5
Re: Pascal accessing shared image data
Posted: Thu Jul 29, 2021 10:31 am
by garyrevell
Thanks everyone for your input.
In the end I've decided to use a simpler method, I've written a simple Pascal function in the shared image that returns the value of the Terminals data structure, and the resulting data works fine for my needs.
Having played about with [COMMON] attribute etc it looks like the shared image is acting a bit like an object in OOP in that it has private data encapsulated in it and public interfaces to this, so I thought might as well use that approach
Re: Pascal accessing shared image data
Posted: Thu Jul 29, 2021 10:45 am
by arne_v
And more long term then I would recommend moving such data to a more general accessible storage.
Like a SQLite database.