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

Stephen Hoffman seaohveh at hoffmanlabs.invalid
Thu Oct 31 17:38:35 EDT 2019


On 2019-10-31 19:26:17 +0000, Craig Dedo said:

> 
> On Thursday, October 31, 2019 at 2:18:28 PM UTC-5, abrsvc wrote:
>> Isn't this essentially the same question that you asked in an earlier 
>> topic with the same title?

Here's the previous thread:

https://groups.google.com/d/msg/comp.os.vms/ucYir_9SwfM/dhHgeO6AAQAJ

>> There are many regular visitors here (myself included) that can 
>> probably help with this, but we usually work as consultants to resolve 
>> these types of issues and get paid.  While it is reasonable to ask 
>> generic questions if you are not sure, this looks more like a 
>> consulting opportunity.
>> 
>> I'd like to help resolve this as this is a very interesting problem, 
>> but consulting is how I make a living and giving away time for free is 
>> not in the cards.
>> 
>> Let me know if you are interested in a shirt term contract to resolve 
>> this. If so, additional information will be required as well as a 
>> reproducer (if possible).
>> 
>> Dan
> 
> No, this is NOT the same question I posted on October 21.  That 
> question concerned passing scalar character strings from C to Basic.  
> This question is about passing arrays of character strings from C to 
> Basic.  I solved the problem in the original question by using 
> fixed-length string descriptors, like I mentioned around halfway thru 
> my original post.  This time I need to use array descriptors.

Both a fixed-length, static (DSC$K_CLASS_S) and a dynamic descriptor 
(DSC$K_CLASS_S) reference an array of characters.

It's seemingly the same question, as passing the address of a different 
data descriptor doesn't appreciably change how any of this stuff works.

Descriptors are not some magical mystery, they're a documented data 
structure.  A data structure passed by reference; by the address of the 
start of the data structure.

C doesn't include language-integrated support for descriptors, so if 
you need a descriptor, you get to build it.

Same sequence as last time, with a different data structure being 
populated and passed.

For the data structures used here, C provides access to the dscdef.h 
include file as well as descrip.h, and the former contains most (all?) 
descriptors known to OpenVMS.

Find out which array data structure is getting passed.   There are 
several array descriptors. Which BASIC might use depends on the BASIC 
source code involved, too.

I'll sometimes use the debugger for that and intercepting a 
same-language-to-same-language call, and examining the argument, if the 
associated documentation doesn't indicate which descriptor is used.  
Switch the debugger language into C or Macro32 and look at the 
arguments arriving in the called code.  Match that up against the 
available descriptors, and you'll have the structures getting used.  
Reverse engineering, as it happens.

Then allocate some storage for the structure, populate it, and pass a 
reference to that structure along to the called routine.

As for alternatives, if you're passing an array of strings, pass along a file.

Better still, expunge the BASIC code entirely, if the folks working 
here are not familiar with mixed-language programming on OpenVMS.  Or 
wrap the BASIC code in something more easily callable.  These 
approaches were mentioned last time too, but I don't recall seeing a 
reply.

> No, a consulting contract is not possible.  I don't have any spending 
> authority for Navistar and I'm not willing to spend my own money on a 
> work-related problem.  I would need to get permission from management 
> and someone in management would need to approve the contract.

If you can't get help, you'll want to get some OpenVMS reading, or some 
OpenVMS development training here, then.

https://vmssoftware.com/docs/VSI_OpenVMS_BaseOS/6641_Prog_Concepts_Vol2.pdf
See 2.5.3. Passing Arguments by Descriptor 

https://vmssoftware.com/docs/VSI_OpenVMS_BaseOS/5492_c_users_gd.pdf
See 3.2.3. Passing Arguments by Descriptor

https://vmssoftware.com/docs/VSI_OpenVMS_compilers_and_lpd/basic/VSI_BASIC_User_Manual.pdf 

17.4. String and Array Descriptor Format

Or call VSI support, and ask for help.  The doc here seems to need some 
help, too. In multiple dimensions, no pun intended.

Or post the entry point declaration of the called BASIC code or 
(better) a standalone BASIC module for folks to test with, and maybe 
somebody here will write some code.





-- 
Pure Personal Opinion | HoffmanLabs LLC 


More information about the Info-vax mailing list