[Info-vax] Any Way to Pass Arrays of Strings from C to Basic?
Dave Froble
davef at tsoft-inc.com
Thu Oct 31 18:36:35 EDT 2019
On 10/31/2019 2:40 PM, Craig Dedo wrote:
> Is there any way to pass arrays of character strings from C to Basic? For both languages I'm using the current versions of the languages:
> VSI C V7.4-002 on OpenVMS Alpha V8.4-2L2
> VSI BASIC V1.8-005 on OpenVMS V8.4-2L2
>
> I need to pass character string variables from a main program or procedure written in C to a subroutine written in Basic and get back character string data from the Basic subroutine. I had to write the subroutine in Basic because it needs to call a utility subroutine in Basic that uses arrays of varying-length character strings.
>
> This post is an expansion of my original post on October 21. This morning management decided that we will be using multiple instances of the same kind of data in one subroutine call. I.e., instead of getting all of the information for one part number at a time we will be getting the information for up to 1000 part numbers at a time.
Had a similar issue, doing a part inquiry over network, Doing 1000 in
one connection sure is better than doing 1000 connections. Had to
educate a web developer.
> Thus, the utility routine that I'm calling from my interface routine in Basic will be returning a 2-D array of varying length character strings. I'm still going to use an interface routine written in Basic so that I can simplify the interface between C and Basic.
>
> In the original problem, using fixed-length character string descriptors worked very well for passing the string arguments from the calling routine in C to the interface routine in Basic. Now I need to write descriptors for arrays of fixed-length character strings.
>
> I tried to research this on my own but came up empty. I have read thru the text of descrip.h, the latest reference manuals and user guides for both Basic and C, and the OpenVMS Programming Concepts Manual. Nothing I have found tells me how to fill in all of the elements in the array descriptor, only some of them.
Frankly, perhaps the best solution would be to write the main program in
Basic.
:-)
> Here is a greatly simplified example. On the C side:
> const size_t STRING_LENGTH = 30;
> const size_t NPARTS = 1000;
> char Part_Number_lsza[NPARTS][STRING_LENGTH+1];
> char Oldest_Invoice_Number_lsza[NPARTS][STRING_LENGTH+1];
> /*
> Make the call to the interface routine written in Basic. The variables ending in _ldsc are the array descriptors for the arrays of character strings.
> */
> Get_DIA_Return_Eligibility ( &Part_Number_ldsc, &Oldest_Invoice_Number_ldsc );
>
> On the Basic side:
> Sub ( String Part_Number_asa(), Oldest_Invoice_Number_asa() )
>
> What I need to learn how to do is to construct the array descriptors for the arrays of strings. I know how to set the fields for the data type, class code, and address but I'm not sure about many of the other fields. Here are some of my questions.
>
> * Should the length of the array element be STRING_LENGTH or STRING_LENGTH+1? I believe it should be STRING_LENGTH but I'm not sure.
>
> * What do dsc$b_scale and dsc$v_fl_binscale do? I'd prefer t use power-of-ten so dsc$v_fl_binscale should be off. Should dsc$b_scale have any value other than zero (0)? If so, wht value should it have?
>
> * I know that dsc$b_dimct should be 1 because I intend to pass 1-dimensional arrays to Basic.
>
> * I believe that dsc$l_arsize should be 31,000 since I need to include a null character at the end of each string element in the array and there are 1000 elements. Is this correct?
>
> * Do I need to include the optional dimension multiplier block? I suspect that yes, I need to include it since I have null-terminated strings in my array so the address difference between array elements is one more than the length of the array element. If so, what should the value of dsc$l_m be?
>
> BTW, this is NOT an academic assignment. It is a real production problem in a commercial environment with real profit and loss responsibility and real money at stake.
As Dan has mentioned, this is what consultants get paid to do. I'm
guessing you're a consultant, so you should understand this.
I do believe that I've mentioned in the past that some people who were
involved in a major way with the development of TOLAS are available.
Not so much as full time people, but for special needs should such arise.
An array of strings in Basic is simply a descriptor representing an
array, and the array elements are themselves string descriptors.
--
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