[Info-vax] Python integration examples

Richard Brodie ergamenes at gmail.com
Tue Dec 15 09:19:38 EST 2020


On Tuesday, 15 December 2020 at 13:48:34 UTC, Marc Van Dyck wrote:
> Apparently it is possible to write code so that a set of routines 
> present in a shareable image can be called from within a Python 
> program. 
> Could someone shed some light, provide examples, any sort of guidance, 
> about how I can actually achieve this ? 

The easiest way to go is through the ctypes module. Once you have a handle
on how it works, it's not too hard to make it work on VMS. 
https://docs.python.org/3/library/ctypes.html

Here's a quick and dirty example with LIBRTL:

>>> from ctypes import c_int, cdll, byref
>>> librtl = cdll.librtl

>>> get_day = librtl.lib$day
  File "<stdin>", line 1
    get_day = librtl.lib$day

OK, dollar in the identifier is a problem. More than one way to do it though.
                        ^
>>> get_day = librtl['lib$day']
>>> day = c_int()
>>> status = get_day(byref(day))
>>> print (status, day)
1 c_long(59198)




More information about the Info-vax mailing list