Pascal accessing shared image data

Post Reply

Topic author
garyrevell
Active Contributor
Posts: 38
Joined: Thu Nov 19, 2020 7:15 am
Reputation: 0
Location: Basingstoke, UK
Status: Offline
Contact:

Pascal accessing shared image data

Post by garyrevell » Thu Jul 22, 2021 11:01 am

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


jreagan
VSI Expert
Master
Posts: 134
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Pascal accessing shared image data

Post by jreagan » Thu Jul 22, 2021 4:42 pm

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.)


Topic author
garyrevell
Active Contributor
Posts: 38
Joined: Thu Nov 19, 2020 7:15 am
Reputation: 0
Location: Basingstoke, UK
Status: Offline
Contact:

Re: Pascal accessing shared image data

Post by garyrevell » Fri Jul 23, 2021 4:05 am

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

User avatar

martinv
Master
Posts: 101
Joined: Fri Jun 14, 2019 11:05 pm
Reputation: 0
Location: Goslar, Germany
Status: Offline
Contact:

Re: Pascal accessing shared image data

Post by martinv » Fri Jul 23, 2021 6:09 am

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.
Working hard for something we don't care about is called stress;
working hard for something we love is called passion.
(Simon Sinek)


jreagan
VSI Expert
Master
Posts: 134
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Pascal accessing shared image data

Post by jreagan » Fri Jul 23, 2021 8:49 am

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?

User avatar

arne_v
Master
Posts: 299
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Pascal accessing shared image data

Post by arne_v » Fri Jul 23, 2021 8:44 pm

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
Arne
arne@vajhoej.dk
VMS user since 1986


Topic author
garyrevell
Active Contributor
Posts: 38
Joined: Thu Nov 19, 2020 7:15 am
Reputation: 0
Location: Basingstoke, UK
Status: Offline
Contact:

Re: Pascal accessing shared image data

Post by garyrevell » Thu Jul 29, 2021 10:31 am

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 ;)

User avatar

arne_v
Master
Posts: 299
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Pascal accessing shared image data

Post by arne_v » Thu Jul 29, 2021 10:45 am

And more long term then I would recommend moving such data to a more general accessible storage.

Like a SQLite database.
Arne
arne@vajhoej.dk
VMS user since 1986

Post Reply