[Info-vax] Any Way to Pass Arrays of Strings from C to Basic?

Dave Froble davef at tsoft-inc.com
Fri Nov 8 14:10:59 EST 2019


On 11/8/2019 1:27 PM, Simon Clubley wrote:
> On 2019-11-08, Bob Gezelter <gezelter at rlgsc.com> wrote:
>> On Friday, November 8, 2019 at 8:16:44 AM UTC-5, Simon Clubley wrote:
>>>
>>> BTW, I don't know DEC Basic. Can you _directly_ call into a DEC BASIC
>>> function from a C language routine and if so, are there limits on
>>> what can be passed from the C routine into the DEC BASIC routine ?
>>>
>>> If there are not, then I don't see why you can't just use one of
>>> the various C language SAX parsers and register your BASIC function
>>> as the callback handler if you didn't want to bother with one of
>>> the DOM style parsers.
>>>
>> Simon,
>>
>> Been there, done that. In a variety of language combinations, some
>> involving BASIC, some not.
>>
>
> So have I in a variety of languages, but never involving DEC Basic...
>
> The kind of thing I was thinking of was if a C routine could pass
> a null terminated string _directly_ into a DEC Basic function or
> if DEC Basic functions could only receive strings when passed in
> by descriptor.

Consider what is happening when a calling routine passes some data by 
reference.  All that is being done is providing an address to a 
location.  Yes, some languages allow for some declarations and testing. 
But still, it is just an address.

Now consider the target routine.  It needs some direction as to what it 
can or should do with that incoming argument.  If it is expecting a WORD 
integer, then it needs a word integer in the argument list.  If it is 
expecting a descriptor, then it needs to set up the proper descriptor in 
the argument list.

It is when there is not agreement on what is at that location in memory 
that the fun starts.

Now, most of the VMS languages play rather well in such an environment. 
Then there is C, which does not play well in that environment.  There is 
the VMS calling standard, and, there is the VMS data types.  Use them, 
and things can work well.  C is not a native VMS language, as far as I 
know, and doesn't embrace the calling standard, nor the data types.

Can you pass the address of the starting location of a zero terminated 
string to a Basic or any other language routine?  Of course you can. 
It's just an address.  The problems start when the language of the 
target routine does not support what is at that location, or, the 
argument in the target routine does not specify the correct data type 
for the argument.

So, if one were to pass the address of a zero terminated string to a 
routine, and the routine "knew" what it was getting, then it is possible 
to handle what is at that location in a custom manner.  Not that such is 
trivial.

As for what type of strings Basic supports, as far as I know it's only 
strings defined by a descriptor.  Not sure if Basic supports all types 
of string descriptors.

>> There are two basic categories of issues:
>>
>> - language RTL initialization; and
>> - headers/bindings
>>
>> Some language RTLs presume, throjugh one path or another, that the INIT
>> routines have been called.  This is easily remedied, but may require some
>> research to determine the right routines to invoke.
>>
>
> Whenever I have encountered the initialisation/setup problem, either
> the main program is written in the non-C language so that's not an
> issue, or there may be documentation stating which language specific
> initialisation routines need to be called from your main program.
>
> Simon.
>


-- 
David Froble                       Tel: 724-529-0450
Dave Froble Enterprises, Inc.      E-Mail: davef at tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA  15486



More information about the Info-vax mailing list