[Info-vax] Any Way to Pass Character String Arguments from C to Basic?

Bob Gezelter gezelter at rlgsc.com
Mon Oct 21 12:38:01 EDT 2019


On Monday, October 21, 2019 at 11:31:33 AM UTC-4, Craig Dedo wrote:
> Is there any way to pass character string arguments from a C program or procedure to a procedure written in 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.
> 
> Everything compiles and links correctly; no errors or warnings at all.  When I run the program everything works fine until I try to assign character string data back into character string arguments that are associated with character strings in the C program.
> * Assignment of character string arguments from the C program to variables in the Basic subroutine works fine.
> * Assignment of integer results from the Basic subroutine to the integer arguments in the C program works fine.
> * BUT when I try to assign character string values to a character string argument in the C program, I get a fatal error:
> %STR-F-FATINTERR, fatal internal error
> 
> I have already documented the fatal error and reported it to our firm's OpenVMS system manager who reported it to VMS Support at VSI a few minutes ago.
> 
> While we are waiting for a reply from VSI, is there any way around this defect in the String module of the OpenVMS Run Time Library?  Here are the procedure interfaces:
> 
> C side (caller):
> void Get_DIA_Return_Eligibility ( struct dsc$descriptor_d *Customer_Location_Code_adsc, struct dsc$descriptor_d *Part_Number_adsc, long *DR3_Quantity_al, long *DR2_Quantity_al, struct dsc$descriptor_d *Oldest_Invoice_Number_adsc, struct dsc$descriptor_d *SQL_Status_adsc, struct dsc$descriptor_d *SQL_Message_adsc );
> 
> Basic side (callee):
> Sub Get_DIA_Return_Eligibility ( String Customer_Location_Code_as, String Part_Number_as, Long DR3_Quantity_al, Long DR2_Quantity_al, String Oldest_Invoice_Number_as, String SQL_Status_as, String SQL_Message_as )
> 
> 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.
> 
> Any help would be very much appreciated.
> 
> Sincerely,
> Craig T. Dedo. OpenVMS Software Development Consultant
> Navistar, Inc.
> 2701 Navistar Drive
> Lisle, IL   60532

Craig,

The key here is that BASIC is expecting strings to be passed by descriptor. The C default is by reference.

One must also be careful about the difference between read only and read/write. 

Look in the C include files for the definition of $DESCRIPTOR. This allows the definition of read-only strings with a descriptor. Writable strings have to be defined differently.

I hope that the above is helpful. If I have not been clear, contact me on or off list.

- Bob Gezelter, http://www.rlgsc.com



More information about the Info-vax mailing list